Survey application with REST API to manage surveys and questions and website, where all surveys are outputted.
You need to have deno installed in order to run this application.
Install also denon which watches your file changes and automatically restarts server.
-
Clone the repository
-
Go to the project root folder
-
Copy
.env.example
into.env
file and adjust the values# MongoDB connect URI MONGODB_URI = mongodb://localhost:27017 # MondoDB database name DB_NAME = deno_survey # JWT encryption/decription secret key JWT_SECRET_KEY = some-random-key # JWT expiration duration JWT_EXP_DURATION = 3600000
-
Run the application by executing
denon run --allow-net --allow-write --allow-read --allow-env --allow-plugin --unstable server.ts
In REST API the following endpoints are supported.
METHOD | URL | Description | Request |
---|---|---|---|
POST | /api/register | Register |
json { "name": "test", "email": "test@example.com", "password": "test" } |
POST | /api/login | Login |
json { "email": "test@example.com", "password": "test" } |
GET | /api/survey | Get surveys for authentication user | (Empty) |
GET | /api/survey/:id | Get single survey | (Empty) |
POST | /api/survey | Create survey |
{ "name": "Survey name", "description": "Survey description" } |
PUT | /api/survey/:id | Update survey |
{
"name": "Survey name",
"description": "Survey description"
} |
DELETE | /api/survey/:id | Delete survey | (Empty) |
GET | /api/survey/:surveyId/question | Get questions for survey | (Empty) |
GET | /api/question/:id | Get single question | (Empty) |
POST | /api/question/:surveyId | Create question for survey |
Single choice question
{
"text": "How much you liked the Deno Course?",
"type": "choice",
"required": true,
"data": {
"multiple": false,
"answers": [
"I liked it very much",
"I liked it",
"I did not like it",
"I hate it"
]
}
}
Multiple choice question
{
"text": "Which features do you like in Deno?",
"type": "choice",
"required": true,
"data": {
"multiple": true,
"answers": [
"Typescript",
"Security",
"Import from URL",
"ES6 modules"
]
}
}
Free text question
{
"text": "Any other comments?",
"type": "text",
"required": false
} |
PUT | /api/question/:id | Update question | |
DELETE | /api/question/:id | Delete question | (Empty) |