An API for storing users, teams, hacks, challenges and sponsors
This API is written in TypeScript with hapi.js using Mongoose for data storage in MongoDB.
(see Running with Docker to get started faster)
You will need installations of the following available:
- Node.js (
node) - currently tested with version 6.9, and running on Heroku on 6.9 - MongoDB (
mongod) - it's recommended to run your own MongoDB rather than let the build pipeline run it for you
-
Install dependencies:
$ npm install
-
Run the API locally. If your MongoDB server is not running on default port on localhost, change the script accordingly.
$ MONGODB_URL='mongodb://localhost/hack24api' npm start Server started on port 5000
The repository includes a Dockerfile and docker-compose.yml file for use with docker-compose. You get started very quickly by simply starting the compose file from the repository path:
docker-compose up -dWhen you're done, destroy it all with:
docker-compose downIf you are developing locally, and would prefer to use docker for MongoDB only, use the following command to run a local version of MongoDB for use with the API:
docker run --rm -p 27017:27017 --name hack24-api-db -d mongo --smallfilesThen stop the database when you're done with:
docker stop hack24-api-dbSince this is a TypeScript project, the .ts files will need to be transcompiled into JavaScript .js files before the test suite can be run. To simplify this, there are two npm scripts which will handle the compilation and testing cycles for you.
-
npm run build -- -wThis will run
tscwith the--watch|wflag to trigger a recompile whenever any files change within thesrcpath (the.tsfiles). Start this in a separate terminal window and leave running while you work. -
npm run test -- -wThis will run
mochawith the--watch|wflag to trigger a run through all tests if it sees the contents of thebuildpath change (the compiled.jsfiles). Also start this process in a new terminal window if you would like a smooth experience.
It's worth deleting the build path and restarting the npm run build -- -w script - this is due to the command being unable to remove any scripts that you may have deleted in the source path, and will eventually become cluttered with deleted files.
Type definitions were replaced with the @types scoped packages, inherited from Definitely Typed definitions. Some local definitions are used also to define smaller interfaces. This means there is no longer a need for the typings tool.