An API for storing users, teams, hacks, challenges and sponsors
Running the Server
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
$ 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
Running with Docker
The repository includes a
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 -d
When you're done, destroy it all with:
If 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 --smallfiles
Then stop the database when you're done with:
docker stop hack24-api-db
Since this is a TypeScript project, the
.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 -- -w
This will run
--watch|wflag to trigger a recompile whenever any files change within the
.tsfiles). Start this in a separate terminal window and leave running while you work.
npm run test -- -w
This will run
--watch|wflag to trigger a run through all tests if it sees the contents of the
buildpath 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