RESTful API service to create, read, update and delete data from the web and mobile applications.
1. Clone this repository using the terminal command or GitHub Desktop.
git clone https://github.com/Forma-AT/forma-core.git2. Install the dependencies using npm
npm i3. Create a file in the project root directory named .env and place the following content in it. Make sure to replace these placeholder values with the actual secrets and connection details you wish to use. The recommended JWT secret is an at least 20 characters long random generated string.
PORT=5000
MONGODB_HOST="localhost"
MONGODB_PORT=27017
MONGODB_POOLSIZE=20
MONGODB_NAME="forma"
JWT_SECRET=""4. Start the server in development mode with TypeScript compilation and hot-reloading enabled
npm run dev5a. (optional) Compile source code manually
npm run build5b. (optional) Start the server in production mode
npm run prod6. Access the API using any client (e.g. Postman) at
http://localhost:5000/apiFor an exhaustive list of all available API endpoints, authorization information, request and response parameters, as well as request and response samples view the API documentation written in OpenAPI 3 format at docs/core-api.yaml. To run a user-friendly API documentation server using redoc-cli run the following command:
npm run apior to run the API server in watch mode (no hot-reloading)
npm run api:devand then open the documentation server in the browser at
http://localhost:8080/When testing the API endpoints or the front-end UI it can come in handy to have test users ready, and manual creation can be tedious. The following command will generate 15 school and 15 teacher accounts, all fully configured and set up. None of the users will have memberships or classes by default.
npm run gen-mock-dataKeep in mind that this should only be run once, otherwise you might end up with duplicate users. To customize the mock data before running the command you can edit the files under scripts/mock. The generated users will have the following format by default:
| Type | Password | |
|---|---|---|
| school | [email protected] | Testing123 | 
| school | [email protected] | Testing123 | 
| ... | ... | ... | 
| school | [email protected] | Testing123 | 
| school | [email protected] | Testing123 | 
| teacher | [email protected] | Testing123 | 
| teacher | [email protected] | Testing123 | 
| ... | ... | ... | 
| teacher | [email protected] | Testing123 | 
| teacher | [email protected] | Testing123 |