├── .env.example
├── .gitignore
├── README.md
├── assets
└── app.css
├── controllers
├── AuthController.ts
├── BaseSurveyController.ts
├── QuestionController.ts
├── SiteController.ts
└── SurveyController.ts
├── deps.ts
├── helpers.ts
├── lock.json
├── middleware
├── authMiddleware.ts
└── staticFileMiddleware.ts
├── models
├── BaseModel.ts
├── Question.ts
├── Survey.ts
└── User.ts
├── mongo.ts
├── rest.http.example
├── router.ts
├── server.ts
└── views
├── notfound.ejs
├── partials
├── footer.ejs
└── header.ejs
├── survey.ejs
├── surveyFinish.ejs
└── surveys.ejs
/.env.example:
--------------------------------------------------------------------------------
1 | # MongoDB connect URI
2 | MONGODB_URI = mongodb://localhost:27017
3 | # MondoDB database name
4 | DB_NAME = deno_survey
5 | # JWT encryption/decription secret key
6 | JWT_SECRET_KEY = some-random-key
7 | # JWT expiration duration
8 | JWT_EXP_DURATION = 3600000
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .env
2 | .deno_plugins
3 | /*.http
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Deno Survey App
2 | Survey application with REST API to manage surveys and questions and website, where all surveys are outputted.
3 |
4 | ## Installation
5 |
6 | You need to have [deno installed](https://deno.land/#installation) in order to run this application.
7 | Install also [denon](https://deno.land/x/denon) which watches your file changes and automatically restarts server.
8 |
9 | 1. Clone the repository
10 | 1. Go to the project root folder
11 | 1. Copy `.env.example` into `.env` file and adjust the values
12 |
13 | ```dotenv
14 | # MongoDB connect URI
15 | MONGODB_URI = mongodb://localhost:27017
16 | # MondoDB database name
17 | DB_NAME = deno_survey
18 | # JWT encryption/decription secret key
19 | JWT_SECRET_KEY = some-random-key
20 | # JWT expiration duration
21 | JWT_EXP_DURATION = 3600000
22 | ```
23 | 1. Run the application by executing
24 |
25 | ```dotenv
26 | denon run --allow-net --allow-write --allow-read --allow-env --allow-plugin --unstable server.ts
27 | ```
28 |
29 | ## Usage
30 |
31 | In REST API the following endpoints are supported.
32 |
33 |
METHOD | 37 |URL | 38 |Description | 39 |Request | 40 |
---|---|---|---|
POST | 45 |/api/register | 46 |Register | 47 |
48 | 49 | json 50 | { 51 | "name": "test", 52 | "email": "test@example.com", 53 | "password": "test" 54 | } 55 |56 | |
57 |
POST | 60 |/api/login | 61 |Login | 62 |
63 | 64 | json 65 | { 66 | "email": "test@example.com", 67 | "password": "test" 68 | } 69 |70 | |
71 |
GET | 74 |/api/survey | 75 |Get surveys for authentication user | 76 |(Empty) | 77 |
GET | 80 |/api/survey/:id | 81 |Get single survey | 82 |(Empty) | 83 |
POST | 86 |/api/survey | 87 |Create survey | 88 |
89 | 90 | { 91 | "name": "Survey name", 92 | "description": "Survey description" 93 | } 94 |95 | |
96 |
PUT | 99 |/api/survey/:id | 100 |Update survey | 101 |
102 | {
103 | "name": "Survey name",
104 | "description": "Survey description"
105 | }
106 | |
107 |
DELETE | 110 |/api/survey/:id | 111 |Delete survey | 112 |(Empty) | 113 |
GET | 116 |/api/survey/:surveyId/question | 117 |Get questions for survey | 118 |(Empty) | 119 |
GET | 122 |/api/question/:id | 123 |Get single question | 124 |(Empty) | 125 |
POST | 128 |/api/question/:surveyId | 129 |Create question for survey | 130 |
131 | Single choice question
132 | {
133 | "text": "How much you liked the Deno Course?",
134 | "type": "choice",
135 | "required": true,
136 | "data": {
137 | "multiple": false,
138 | "answers": [
139 | "I liked it very much",
140 | "I liked it",
141 | "I did not like it",
142 | "I hate it"
143 | ]
144 | }
145 | }
146 | Multiple choice question
147 | {
148 | "text": "Which features do you like in Deno?",
149 | "type": "choice",
150 | "required": true,
151 | "data": {
152 | "multiple": true,
153 | "answers": [
154 | "Typescript",
155 | "Security",
156 | "Import from URL",
157 | "ES6 modules"
158 | ]
159 | }
160 | }
161 | Free text question
162 | {
163 | "text": "Any other comments?",
164 | "type": "text",
165 | "required": false
166 | }
167 | |
168 |
PUT | 171 |/api/question/:id | 172 |Update question | 173 |174 | |
DELETE | 177 |/api/question/:id | 178 |Delete question | 179 |(Empty) | 180 |