Swidler Quiz App is a Node.js application that provides a backend API for quiz functionalities. This documentation provides steps to set up the app locally and details about the API endpoints.
- Node.js and npm installed.
- PostgreSQL installed and running.
-
Clone the Repository:
git clone https://github.com/VitaliyBogdanuk/swidler-quiz-app-server.git cd swidler-quiz-app-server
-
Install Dependencies:
npm install
-
Setup PostgreSQL:
- Ensure PostgreSQL is running.
- Create a new database for the app.
- Create your
config/config.json
file based onconfig/config_template.json
- Update the
config/config.json
file with your database credentials. - Create your
.env
file based on.env_template
- Update the
.env
file with your settings. - Ask your teamlead about GOOGLE_CLIENT_ID GOOGLE_CLIENT_SECRET
-
Run Migrations and Seeds:
npm run db:migrate npm run db:seed
You can use this command to drop the tables database, be carefull because all your data will be removed.
npm run db:migrate:drop
-
Start the App:
npm run start
-
Open browser and find Swagger API Documentation by URL:
http://localhost:[your-port]/api-docs
-
Use this command for generating new migration
npx sequelize-cli migration:generate --name create-[table-name]
-
Use this command for generating new seed for table
npx sequelize-cli seed:generate --name seed-[table-name]
To generate and view the Swagger documentation for the API:
-
In your route files, add JSDoc comments to document your API endpoints. For example:
/** * @swagger * /api/situations: * get: * description: Retrieve all situations * responses: * 200: * description: List of all situations */ router.get('/situations', ...);
-
Start your app and navigate to
http://localhost:[your-port]/api-docs
to view the Swagger documentation.