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

5f8a0b7 · May 23, 2022

History

90 Commits
Aug 7, 2021
May 23, 2022
Apr 5, 2021
Apr 5, 2021
Aug 7, 2021
Jan 25, 2019
May 27, 2020
Apr 5, 2021
Aug 7, 2021
Apr 5, 2021
Apr 5, 2021

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