This project is an Express API for a comp-4537-assignment, which includes various endpoints for user authentication, chat message handling, image generation, and more.
To get the project up and running on your local machine, follow these steps:
- Clone the repository to your local machine.
- Install the required dependencies by running
npm install. - Set up your environment variables by creating a
.env.localfile with the necessary configurations. - Start the development server by running
npm run devStart.
The API includes the following features:
- User registration and authentication
- Password reset functionality
- Chat messaging with AI
- AI-based image generation
- Admin functionalities like resetting API call counts and deleting users
API documentation is available at the /doc/ endpoint once the server is running. It is generated using Swagger and provides detailed information about each endpoint, including the expected request and response formats.
The following environment variables are required:
PORT: The port number on which the server will listen.POSTGRES_DATABASE: The name of the PostgreSQL database.POSTGRES_USER: The PostgreSQL user.POSTGRES_PASSWORD: The password for the PostgreSQL user.POSTGRES_HOST: The host of the PostgreSQL server.POSTGRES_PORT: The port number of the PostgreSQL server.OPENAI_API_TOKEN: The API token for OpenAI services.ANTHROPIC_API_TOKEN: The API token for Anthropic services.SECRET_KEY: A secret key used for JWT token generation and verification.
The package.json file includes the following scripts:
devStart: Starts the development server using nodemon.
This project uses the following main dependencies:
express: Web framework for Node.js.sequelize: ORM for PostgreSQL.bcrypt: Library for hashing passwords.jsonwebtoken: Library for working with JSON Web Tokens (JWT).swagger-jsdoc: Library for generating Swagger docs based on JSDoc comments.swagger-ui-express: Middleware for serving the Swagger UI.
The project is set up with ESLint for code linting and nodemon for automatically restarting the server during development.
The .gitignore file is configured to exclude the following directories and files from version control:
node_modules/: Node.js modules..env: Environment variables file..env.local: Local environment variables file.
ChatGPT and Claude was used to assist in the development of this project.
The API is developed by students of COMP 4537.
For more information on how to use the API, refer to the Swagger documentation generated at the /doc/ endpoint.