An Express API for creating, reading, and updating DCP Applicant Maps. It uses mongodb to store documents for an applicant mapping project.
Works with the labs-applicantmaps frontend app.
You will need the following things installed on your computer.
- Git
- Node.js version listed in .nvmrc
- We suggest installing versions of Node via nvm.
- Yarn v1.x
- Nodemon
- Docker
- Docker compose v2
- Compose is available as a CLI plugin or through a setting in Docker Desktop
- Run MongoDB in docker
docker compose up
- Install the listed version of Node
- (If using nvm)
nvm install
- (If using nvm)
- Install Yarn and Nodemon
npm i --location=global yarn nodemon
- Install Dependencies using Yarn
yarn
- Copy the contents of
env.example.local
to a new file called.env
. The contents of.env.example.local
are pre-configured to connect to the database created bycompose.yaml
cat .env.example.local > .env
(or manually create the file, then copy and paste)
- Start the api server by running
yarn run dev
GET /projects/:id
- Get a project's config by id
POST /projects
- Create a new project
POST /projects/:id
- Update an existing project by id. This results in incrementing the
__v
attribute in mongodb.
When deploying, create a .env
file based on .env.example
.
MONGO_URI
- the connection string for the mongodb database
NODE_ENV
- 'development', 'staging', or 'production'
Schema is defined in models/projects.js
. On creation of a new project, shortid
is used to generate a unique hash that is stored in the _id property
{
_id: {
type: String,
required: true,
default: shortid.generate(),
},
meta: {
type: Object,
required: true,
},
maps: {
type: Array,
required: true,
},
}