Server template for deno
Instructions for installing Deno can be found here
Denon is the Deno equivalent to nodemon. Denon installation instructions here. If you have problems with Denon after a Deno upgrade, I recommend a reinstallation of Denon as it fixed the issue for me.
Trouble using Deno with Bash or zshrc? Add PATH exports to your .bashrc or .zshrc file. See here
Likewise for Denon, see here
Start the application from the root directory with Deno using deno run --allow-net server.ts
Start the application from the root directory with Denon using denon run --allow-net server.ts
Adding functions for handling various aspects of the server such as getting what you need from the database (ORMs for example) belong in the methods folder.
Middleware such as loggers, timers, error handlers, setting headers, etc belong in the middleware folder.
Routes belong in routes.ts in the api folder. An example route has been provided, but more complex examples are available here
Dependencies for the regular project belong in deps.ts. Dependencies used only during development (such as testing libraries) belong in dev_deps.ts.
Example test of the /route data and response returning correctly. If you don't correctly close the server with AbortController, your tests will hang. To run the test here, which spins up and accesses the network, you'll need to run deno test --allow-net
.
- Level Up Tutorials - The project structure here was learned through this tutorial, and there are many more tutorials on Level Up Tuts. Highly recommend purchasing a Pro subscription!
- Oak Documentation - The documentation for oak includes middleware such as the logger and timer added to this repository. Closing the server was particularly helpful in writing the server test, and it includes middleware for logger and timing.
- Deno Documentation - The deps.ts and dev_deps.ts approach comes from this section.