Boilerplate for deno development. Mongo, Oak, React, Deno (MORD stack).
- Docker containers
- Redis for sessions
- Folder by Feature structure
- Minimal Material UI v4 design
- Built-in dark theme switch
- Built-in React routing, Redux
- Built-in local authentication
- Handling database with deno_mongo
- Email sending by deno-smtp
- Using std log for logging
- Testing with the built-in test runner
- Clean code with the built-in formatter
- Deno bundler support
These are the planned updates of the project.
- Rhum testing
- SSL support
- Websocket support
- Google login
- PayPal payment
- Email templates
Since the deno and it's modules are not stable yet, breaking changes could happen to this project!
- Clone the repository
- Install dependencies (frontend)
- Set env variables
- Create database
git clone https://github.com/tamasszoke/deno-seed.git
Run npm install
at the frontend folder
Create .env.development
and .env.production
files inside frontend/
folder.
Use port 3002
for development and port 80
for production.
Example (include all of these):
HOST=0.0.0.0
PORT=3002
REACT_APP_PROTOCOL=http
REACT_APP_HOST=localhost
REACT_APP_PORT=5000
SKIP_PREFLIGHT_CHECK=true
CHOKIDAR_USEPOLLING=true
Located at frontend/.env.development
.
Note: if you change the ports change them in the dockerfiles too (root, backend).
Create .env.test
, .env.development
and .env.production
files inside backend/.env/
folder.
Use port 5000
for test, development and port 80
for production.
Example (include all of these):
APP_NAME=Deno Seed
IP=0.0.0.0
HOST=localhost
PORT=5000
PROTOCOL=http
CLIENT_PROTOCOL=http
CLIENT_HOST=localhost
CLIENT_PORT=3002
REDIS_HOST=redis
REDIS_PORT=6379
DB_HOST=[MLAB_DB_URL]
DB_NAME=[MLAB_BD_NAME]
DB_USER=[MLAB_DB_USERNAME]
DB_PASS=[MLAB_DB_PASSWORD]
EMAIL_ADDRESS=[GMAIL_ADDRESS]
EMAIL_PASS=[GMAIL_PASSWORD]
Located at backend/.env/.env.development
.
Note: if you change the ports change them in the dockerfiles too (root, backend).
Create MongoDB with a collection called users
.
I've used the free service provided by mLab.
Note: use the following commands at the root folder.
- Start
docker-compose -f docker-compose.development.yml up
- Go to
http://localhost:5000
in browser for server - Go to
http://localhost:3002
in browser for client
- Run
sh build.sh
- Start
docker-compose -f docker-compose.production.yml up -d
- Go to
http://localhost:80
in browser
Note: run npm rebuild node-sass
inside the client container if asked.
Using separated docker-compose files for development and production.
Start: docker-compose -f docker-compose.development.yml up
Stop: docker-compose -f docker-compose.development.yml down
Start: docker-compose -f docker-compose.production.yml up
Stop: docker-compose -f docker-compose.production.yml down
Note: don't forget to start your redis server or it will fallback to use the memory for the sessions.
- Start
sh dev.sh
at the root folder (or manually start the denon scripts) - Go to
http://localhost:5000
(backend) - Go to
http://localhost:3002
(frontend)
- Run
sh build.sh
at the root folder - Run
denon prod
at the build folder - Go to
http://localhost:80
Note: you may need to install Denon.
Using typescript .ts
files and the built-in formatter for deno.
Using the built-in testing library and Superoak with integration tests only, because of the higher ROI. The integration tests will cover the basic functions of the application, you can find them in the backend/app.test.ts
.
Using .env
files to set up the basics with the dotenv third party module.
The main variable is the ENV which can be development or production.
This will search for the correct env file to use in the backend/src/config/services/settings.ts
, defaults to test.
The middleware framework is the Oak library along with the Cors module to avoid CORS problems.
The session handled by the third party module, Session, it adds a middleware to the application, so we can get the session variables from any route by using context.session
.
The database is MongoDB using the Mongo (deno_mongo) module. Created a reusable class which is connecting to the database only once, and using that connection for the future queries. Validating the user schema with the Validasaur module.
Using the built-in logger, created two main types, the default and the test, which is only logging critical levels, to hide debug logs during the tests.
The passwords are hashed with salt (different for every user), using the Bcrypt library.
The routing is in the following format: api/service/type/action For example, to login, use: api/auth/local/login
Using Denon, the scripts are format
, test
, start
, prod
.
Name | Version |
---|---|
oak | main branch |
bcrypt | 0.2.3 |
mongo | 0.9.1 |
log | 0.61.0 |
session | master branch |
dotenv | master branch |
validasaur | 0.9.4 |
deno-smtp | tamasszoke fork |
cors | master branch |
superoak | 2.0.0 |
Unfortunately some packages are not refreshing their releases actively (or not published any), so I had to use the master branch of them.
Name | Version |
---|---|
@material-ui/core | ^4.4.2 |
@material-ui/icons | ^4.4.1 |
@material-ui/styles | ^4.4.1 |
animate.css | ^3.7.2 |
axios | ^0.19.0 |
node-sass | ^4.12.0 |
react | ^16.9.0 |
react-dom | ^16.9.0 |
react-material-ui-form-validator | ^2.0.9 |
react-notifications-component | ^2.0.7 |
react-redux | ^7.1.1 |
react-router-dom | ^5.0.1 |
react-scripts | 3.1.1 |
redux | ^4.0.4 |
redux-persist | ^6.0.0 |
The MIT License (MIT)
Copyright (c) 2020 Tamas Szoke
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.