This guide will help you set up the project, configure the environment, and run it locally or on Vercel.
Ensure you have the following installed:
First, clone the repository and navigate into the project directory:
git clone https://github.com/GlitchBanger/QuizAppSvelte.git
cd QuizAppSvelte
Install all necessary dependencies by running:
npm install
Create a .env
file in the root of the project, and add the following environment variables:
DATABASE_URL=postgres://username:[email protected]:5432/dbname?sslmode=require
LOCAL_URL=https://localhost:3000
DB_USER=your_db_user
DB_HOST=your_db_host
DB_NAME=your_db_name
DB_PASS=your_db_password
DB_PORT=5432
PGSSLMODE=no-verify
NODE_TLS_REJECT_UNAUTHORIZED='0'
DATABASE_URL
and other fields according to your PostgreSQL instance.After setting the environment variables, run the following command to generate Drizzle migrations:
npm run generate
Once the migration files are generated, apply them to your PostgreSQL database:
npm run migrate
This will update the database schema as defined in your models.
To start the project in development mode with hot-reloading:
npm run dev
By default, the app should be accessible at http://localhost:3000
.
To build the project for production:
npm run build
Once the project is built, you can preview it in production mode:
npm run preview
If you wish to deploy the project to Vercel, follow these steps:
Make sure you have the Vercel CLI installed:
npm install -g vercel
Use the following command to deploy:
npx vercel
Follow the prompts, and your app will be deployed to Vercel.
SSL Issues (SELF_SIGNED_CERT_IN_CHAIN): You may encounter this issue due to SSL certificates. You can disable SSL verification in development by using NODE_TLS_REJECT_UNAUTHORIZED='0'
and PGSSLMODE=no-verify
. This should not be done in production.
Database Connection Issues: Ensure the PostgreSQL service is running and that the DATABASE_URL
and other connection variables in .env
are correct.
For any other issues, consult the project documentation or raise an issue in the project's GitHub repository.
/api
/students
/students
200 OK
: Returns a list of all students./teachers
/teachers
200 OK
: Returns a list of all teachers./teachers
{
"name": "string",
"email": "string",
"password": "string"
}
200 OK
: Returns the ID, name, and email of the newly created teacher.400 Bad Request
: Returns error details if the request body is invalid.500 Internal Server Error
: Returns error details if the server fails to create the teacher./teachers/login
{
"email": "string",
"password": "string"
}
200 OK
: Returns a success message if authentication is successful.401 Unauthorized
: Returns error details if authentication fails.500 Internal Server Error
: Returns error details if the server fails to authenticate./tests
/tests
createdBy
(optional): Filter tests by the creator's ID.200 OK
: Returns a list of tests.500 Internal Server Error
: Returns error details if the server fails to fetch tests./tests
{
"title": "string"
}
createdBy
: ID of the user creating the test.200 OK
: Returns the ID of the newly created test.400 Bad Request
: Returns error details if createdBy
is missing or the request body is invalid.500 Internal Server Error
: Returns error details if the server fails to create the test./tests
testId
: ID of the test to be deleted.200 OK
: Returns a success message if the test is deleted successfully.400 Bad Request
: Returns error details if testId
is missing or invalid.404 Not Found
: Returns error details if the test is not found.500 Internal Server Error
: Returns error details if the server fails to delete the test./tests/questions
/tests/questions
testId
(optional): Filter questions by test ID.200 OK
: Returns a list of questions.500 Internal Server Error
: Returns error details if the server fails to fetch questions./tests/questions
{
"questionText": "string",
"optionA": "string",
"optionB": "string",
"optionC": "string",
"optionD": "string",
"answerKey": "A" | "B" | "C" | "D"
}
testId
: ID of the test to which the question belongs.200 OK
: Returns the ID of the newly created question.400 Bad Request
: Returns error details if testId
is missing or the request body is invalid.500 Internal Server Error
: Returns error details if the server fails to create the question./tests/questions
{
"questionText": "string",
"optionA": "string",
"optionB": "string",
"optionC": "string",
"optionD": "string",
"answerKey": "A" | "B" | "C" | "D"
}
questionId
: ID of the question to be updated.200 OK
: Returns the updated question details.400 Bad Request
: Returns error details if questionId
is missing or the request body is invalid.500 Internal Server Error
: Returns error details if the server fails to update the question./tests/questions
questionId
: ID of the question to be deleted.200 OK
: Returns a success message if the question is deleted successfully.400 Bad Request
: Returns error details if questionId
is missing or invalid.404 Not Found
: Returns error details if the question is not found.500 Internal Server Error
: Returns error details if the server fails to delete the question./tests/createresponse
/tests/createresponse
testId
: ID of the test.studentId
: ID of the student.200 OK
: Returns the ID of the created or existing test response.400 Bad Request
: Returns error details if testId
or studentId
is missing.500 Internal Server Error
: Returns error details if the server fails to create or fetch the test response./tests/questionresponse
/tests/questionresponse
200 OK
: Returns a list of all question responses.500 Internal Server Error
: Returns error details if the server fails to fetch question responses./tests/testresponse
/tests/testresponse
responseId
: ID of the test response.200 OK
: Returns the test response details, including correctness of each question.400 Bad Request
: Returns error details if responseId
is missing.404 Not Found
: Returns error details if the test response is not found.500 Internal Server Error
: Returns error details if the server fails to fetch the test response details./tests/registerresponse
/tests/registerresponse
{
"selectedOption": "A" | "B" | "C" | "D"
}
responseId
: ID of the test response.questionId
: ID of the question.200 OK
: Returns a success message if the response is registered or updated successfully.400 Bad Request
: Returns error details if responseId
or questionId
is missing.500 Internal Server Error
: Returns error details if the server fails to register or update the response./tests/testresponses
/tests/testresponses
testId
: ID of the test.200 OK
: Returns a list of test responses with student details and correctness.400 Bad Request
: Returns error details if testId
is missing or invalid.404 Not Found
: Returns error details if no test responses are found.500 Internal Server Error
: Returns error details if the server fails to fetch test responses./tests/answerkey
/tests/answerkey
responseId
: ID of the test response.200 OK
: Returns the answer key with selected options for the test response.400 Bad Request
: Returns error details if responseId
is missing or invalid.404 Not Found
: Returns error details if the test response is not found.500 Internal Server Error
: Returns error details if the server fails to fetch the answer key.