This project is a backend service built with Next.js, Prisma, and TypeScript. It provides a set of API endpoints for managing feedback and contact information for an Enterprise-Ready XM Backend.
- .env: Environment variables configuration.
- .next: Next.js build output.
- prisma: Contains Prisma schema and migration files.
- src: Source code for the application.
app/: Contains API route handlers.utils/: Utility functions.- client.ts: Prisma client instance.
- next.config.ts: Next.js configuration file.
- tsconfig.json: TypeScript configuration file.
- package.json: Project dependencies and scripts.
The .env file contains the following environment variables:
DATABASE_URL="your database connection string"
NEXTAUTH_SECRET="your next-auth secret"
Prisma uses this variable to connect to the PostgreSQL database.
- GET /api/feedback: Retrieve all feedback.
- POST /api/feedback: Create new feedback.
- GET /api/feedback/[id]: Retrieve feedback by ID.
- PUT /api/feedback/[id]: Update feedback by ID.
- DELETE /api/feedback/[id]: Delete feedback by ID.
- GET /api/contact: Retrieve all contacts.
- POST /api/contact: Create new contact.
- GET /api/contact/[id]: Retrieve contact by ID.
- PUT /api/contact/[id]: Update contact by ID.
- DELETE /api/contact/[id]: Delete contact by ID.
This project uses NextAuth.js for authentication. The authentication strategy is based on JWT (JSON Web Tokens) and credentials provider.
To register a new user, send a POST request to /api/register with the following JSON payload:
{
"email": "user@example.com",
"password": "yourpassword",
"name": "Your Name"
}To log in, send a POST request to /api/login with the following JSON payload:
{
"email": "user@example.com",
"password": "yourpassword"
}The response will contain a JWT token that you can use to authenticate your requests.
To authenticate your requests, include the JWT token in the Authorization header as follows:
Authorization: Bearer <your-jwt-token>
- Install dependencies:
npm install- Set up the database:
npx prisma migrate dev- Start the development server:
npm run devTo run the tests, use the following commands:
- Run all tests:
npm run test- Run tests in watch mode:
npm run test:watch- Generate a test coverage report:
npm run test:coverageThis project is licensed under the MIT License. See the LICENSE file for details.