Skip to content

Sonic12040/deno-oak-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

deno-oak-server

Server template for deno

Installing Deno

Instructions for installing Deno can be found here

Installing Denon (optional)

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.

Common Problems

Trouble using Deno with Bash or zshrc? Add PATH exports to your .bashrc or .zshrc file. See here

Likewise for Denon, see here

Starting the application

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 methods

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.

Adding middleware

Middleware such as loggers, timers, error handlers, setting headers, etc belong in the middleware folder.

Adding routes

Routes belong in routes.ts in the api folder. An example route has been provided, but more complex examples are available here

deps.ts and dev_deps.ts

Dependencies for the regular project belong in deps.ts. Dependencies used only during development (such as testing libraries) belong in dev_deps.ts.

server.test.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.

Recommended Resources

  • 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.

About

Server template for deno

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published