Foundation for a backend server, database, session management & API.
- Database is PostgreSQL
- Database pool instantiator,
database/Database.js - Router & routes follow a specific design pattern - see below
- Dotenv is used to pull environment variables from the
.envfile- Use
.env.samplefor all of the default values, which can be copied into.env .env.sampleis never used in the program
- Use
- .gitignore is provided with usual Node.JS ignores +
.env src/utilincludes common utility files- Mocha is included for testing, including default tests
- Nodemon is included for rapid development iteration
- Dockerfiles & Docker Compose are included for a consistent development environment
npm install - Installs packages from package.json into node_modules
npm start - Default, runs normally
npm run start-dev - Run using nodemon
npm run test - Runs all the tests within the test folder.
A default test is provided, called foundation.js.
The router pulls all of the routes within the src/routes folder and uses the folder(s) + filename exactly, unless the endpoint variable is passed back.
Each individual file in src/routes is treated as a single API endpoint.
Example: If the folder structure & file is src/routes/ping/ok.js, then the API call will generate the endpoint at ping/ok. If the file returns an endpoint variable, it will override the default endpoint from the folder structure.
For ease of use, Dockerfiles and a Docker Compose file are provided for portability.
docker-compose build
docker-compose up -d
docker-compose down
Each file uses tab-indentation prior to code. Tab size does not matter, this is a user-preference that does not affect anyone else's workflow or code readability.
When aligning lines of values together for readability, use spaces following the first non-tab character. This guarantees that alignment is preserved across users and code review services.
// Tabs for indentation, spaces for alignment
function send(res, code, data) {
let payload = {
'data' : data || {},
'status' : code || 500
};
res.send(payload);
return res.end();
}
This server software was designed by our developers at Blockade Games, either directly or indirectly.
- Adam Gibbons
- Adrian Seeley
- Ben Heidorn
- Chris Chapman
- Rhea Myers
- Troy Salem