This is the solution for the individual challenge of the hackathon Hack That Startup v3.
Deployed: App
Clone the repository
npm clone
Install the dependencies:
npm install
Make sure to create your own environment file in src/config folder. There is a sample.env, copy it and use your own variables.
Start in development mode: (Server on watch mode)
npm start
The project testing is done using Jest
and Supertest
modules.
When the testing environment is running, Jest cannot read .env files with env-cmd
module. For that reason, the enviroment variables are served by a JavaScript file in .jest folder. There is a sample that needs to have the asked variables.
Then, the test environment can be run.
npm test
All the typescript code is in src folder.
Folder / File | Description |
---|---|
api | All business logic and model handlers. |
app | Express server configuration (DB, HELMET, ...). |
bin | Server Port configuration. |
config | Environment variables depending on server status (dev, prod, test, ...). |
graphql | GraphQL Api files (schema, types, resolvers,...). |
routes | Main route file for app server |
scripts | Isolated functions |
tests | Testing functions |
app.js | Server declaration and configuration |
Compiler to high compability JavaScript version
npm run build
Server on development mode (ES6 or later).
npm start
Start high compability server
npm run serve
Delete compiled JavaScript code
npm run clean
Start test environment
npm test
Force heroku to run npm build before the start
npm run heroku-postbuild
All the routes are defined following REST convention.
Return all users:
- GET: /api/user
Return one user by id:
- GET: /api/user/:id
Create one user
- POST: /api/user
Updated one user by id
- PATCH: /api/user/:id
Delete one user by id
- DELETED: /api/user/:id
Return all repositories:
- GET: /api/repository
Return one repository by id:
- GET: /api/repository/:id
Create one repository
- POST: /api/repository
Updated one repository by id
- PATCH: /api/repository/:id
Delete one repository by id
- DELETED: /api/repository/:id
The GraphQL API is an addition, can interact with the models and make requests to database.
The setup is done but some implementations are missing for now