An open API service indexing awesome lists of open source software.

https://github.com/thecodeholic/deno-survey

Survey Application made with Deno
https://github.com/thecodeholic/deno-survey

deno deno-app deno-rest-api deno-survey denoland

Last synced: 3 months ago
JSON representation

Survey Application made with Deno

Awesome Lists containing this project

README

        

# Deno Survey App
Survey application with REST API to manage surveys and questions and website, where all surveys are outputted.

## Installation

You need to have [deno installed](https://deno.land/#installation) in order to run this application.

Install also [denon](https://deno.land/x/denon) which watches your file changes and automatically restarts server.

1. Clone the repository
1. Go to the project root folder
1. Copy `.env.example` into `.env` file and adjust the values

```dotenv
# 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
```
1. Run the application by executing

```dotenv
denon run --allow-net --allow-write --allow-read --allow-env --allow-plugin --unstable server.ts
```

## Usage

In REST API the following endpoints are supported.



METHOD
URL
Description
Request




POST
/api/register
Register


json
{
"name": "test",
"email": "[email protected]",
"password": "test"
}




POST
/api/login
Login


json
{
"email": "[email protected]",
"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)