a production ready deno starter focused on making tacos. Setup with redis, mongodb, and meilisearch model syncing.
You can start the application locally or using docker. The simplest option to get started is using docker and compose.
make sure to have docker and compose installed. The docker image is using a slim alpine build. On intial container start, its safe to ignore the log output /usr/lib/libstdc++.so.6 on the alpine image.
docker-compose up
Make sure to have deno installed. If your using mac you can use brew install deno
. If your starting the application locally make sure to have mongodb running for database operations. You need to add a .env
file and add DB_URL=$URL_DB_URL
, replace $URL_DB_URL
with your database endpoint.
deno run --allow-read --allow-env --allow-net main.ts
Pages are views that are server side rendered.
url | params | models | description |
---|---|---|---|
/pages/orders | no | Orders | Get a list of recent orders from redis |
/pages/order | no | Orders | Find order from redis or meilisearch |
/pages/create | no | Orders | Create a new random order |
REST validation is done through validator-middleware.
below are a list of custom middlewares in registration order.
Below are a list of databases used. Mongodb is one of the databases used in the application. If your using docker and need an admin tool navigate to localhost:8081
. We use meilisearch for the search server.
The app is setup with assertion testing that handles redirection to valid responses for a rest api. When building new features handle the validation through assertions inside the file.
To run unit test|e2e|intg run deno test --allow-read
.
For integration test run ./integrations/run.sh
.
The benchmarks are located in the benchmarks directory. On each suite the rate limiting middleware is disabled. Please do not run in production since this will adjust the runtime of your server. Read benchmarks-docs for more information on the type of test, how to, average, and etc.
Environmental variables are handled through .env files. For an example look at the usage below. Check out .env.defaults to see the full list.
PORT=8000
MONGO_DB_PORT=27017
MONGO_DB_NAME=taco-rocket
MONGO_DB_URL=mongodb://mongodb:27017/?compressors=zlib&gssapiServiceName=mongodb
MONGO_DB_RETRY_TIMOUT=15000
MEILISEARCH_DB_API_KEY=masterKey
REDIS_DB_URL=redis
SYSTEM_ADMIN_PASSWORD=password
All routers in the routes
folder are autoloaded into the application. Simply export as a named export called router
.
To get started with testing the api you can use the fixtures
inside the project. For more information read fixtures-doc
Compiling the taco creator visual is done with web assembly. To build the binary run ./assembly/build.sh
which outputs the file into the src/assets/static
folder. Make sure to have AssembyScript installed locally.
./assembly/build.sh
Deployment is done using ECS for clustering, security groups, load balancing, logging, volumes, and elastic scaling. The docker image used for the api is at image
This apps main goal is for CRUD, architecture, and security. Since security is a core focus for the application we are using Deno for the backend along with oak as a middleware framework ("express like"). When you post an order, if the option is not a part of the ingredient list the order will be rejected with output of valid options. The ingredient list is in memory using enum
. If we want to add the ability to add to the ingredients list we can either mutate the enum at runtime or use the database with a seed
step to generate the intial ingredients based off the enums. For now neither was done and the option to add a new ingredient is set by bypassing the available options through the customIngredients
property in the order item. For an example checkout custom-order-fixture. Rate limiting is added as a security feature to protect against DDOS. The current rate is set to 2 request per 3 seconds, to adjust the middleware go to Rate Limiting.