Progressive Startup API Boilerplate
https://firestarter-api.andromeda.technology
Easy to extend, Progressive and Scalable API boilerplate to power your startup.
- TypeScript,
- Koa.js,
- Database: MongoDB: Mongoose,
- Config: Dotenv, Joi,
- Testing: Jest: SuperTest, MongoDBMemoryServer,
- Docker: MongoDB.
- Clone the repo,
- Duplicate
.env.examplefiles in [./,/docker/] to.env; modify as needed, - Have
Dockerinstalled, run the containers and your app (check the instructions below), - Add modules (routes, controllers, services, tests) to
/src(duplicate Message module, adjust to your needs), - List newly added modules (features) here (Readme.md) and in your POSTMAN collection.
- Message Module,
- [Add your modules/features here]
All API routes are prefixed by API_PREFIX (defined in.env) (default: /api).
Docker
Docker provides isolated MongoDB for your project.
cd ./docker
# Duplicate example env file, modify as needed
cp .env.example .env
docker-compose up -d
Application
# Return from `docker` to root dir
# cd ..
# Duplicate example env file, modify if needed
cp .env.example .env
# Install packages
npm i
# Run
npm run dev
Using Jest Testing Framework.
Jest uses SuperTest and MongoDBMemoryServer.
npm run test
- (Link your Postman Documentation here)
Pre-set environment variables:
hostadmin_password
Dynamic environment variables, automatically set in tests:
access_token
Routes can be protected with jwtCheck middleware,
requiring admin rights.
Requests going to these routes require Authorization: Bearer {access_token} header.
List of protected, i.e. Admin Routes
- Message[Create,Update,Delete],
- [Add your protected routes here]
Getting access_token for the Admin user
- Request endpoint:
POST /auth/token, - Pass your password in the request body:
{ password: ADMIN_PASSWORD }, - Response will return created
token.
Note: Postman collection will automatically set access_token environment variable,
so you can immediately call admin routes, without copy-pasting it or setting the env variable manually.
Getting the ADMIN_PASSWORD
- Your
ADMIN_PASSWORDis defined in.envfile. - It defaults to
secret.
If you use MongoDB Atlas: Uncomment and fill DB_URI in .env.
Andromeda
Hero image source: FireStarter, gilad, DevianArt.
- State-of-the-art tracker for emotions, habits and thoughts,
- Healthiest version of you,
- Gamified,
- Anonymous and open source.
Check Self-Aware Software Artisan before contributing.