Skip to content

This Project is inspired by https://github.com/jinjor/deno-playground/tree/master/expressive it shows a solution to run a Deno Webserver like the node express way

License

Notifications You must be signed in to change notification settings

NMathar/deno-express

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deno Express

Build Status

Node Express way for Deno

This Project is inspired by https://github.com/jinjor/deno-playground/tree/master/expressive it shows a solution to run a Deno Webserver like the node express way

Example

server.ts File

import * as expressive from "https://raw.githubusercontent.com/NMathar/deno-express/master/mod.ts";

const port = 3000;
const app = new expressive.App();
app.use(expressive.simpleLog());
app.use(expressive.static_("./public"));
app.use(expressive.bodyParser.json());
app.get("/api/todos", async (req, res) => {
  await res.json([{ name: "Buy some milk" }]);
});
// route with dynamic parameter
app.get("/api/user/{user_id}", async (req, res) => {
  await res.json([
    { id: req.params.user_id, name: "Jim Doe", phone: "12425323" },
  ]);
});
const server = await app.listen(port);
console.log("app listening on port " + server.port);

Start app

deno run --allow-net --allow-read server.ts

About

This Project is inspired by https://github.com/jinjor/deno-playground/tree/master/expressive it shows a solution to run a Deno Webserver like the node express way

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published