Skip to content

Commit f666857

Browse files
committed
Fixed tabulation
1 parent 5d49036 commit f666857

File tree

6 files changed

+416
-425
lines changed

6 files changed

+416
-425
lines changed

source/api/v1/handlers/AuthHandlers.ts

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,22 @@ export const handleAuthRoutes = (
2727
}>("/auth", {
2828
schema: AuthUserSchema
2929
}, async (request, reply) => {
30-
const credentials: UserCredentials = request.body
31-
32-
const result = await authService.authorizeAndGetToken(
33-
credentials.email,
34-
credentials.password
35-
)
36-
if (isException(result)) {
37-
reply.code(result.statusCode).send(result)
38-
return
39-
}
40-
41-
reply.code(200).send({
42-
token: result[0],
43-
expiresIn: result[1]
44-
})
30+
const credentials: UserCredentials = request.body
4531

32+
const result = await authService.authorizeAndGetToken(
33+
credentials.email,
34+
credentials.password
35+
)
36+
if (isException(result)) {
37+
reply.code(result.statusCode).send(result)
38+
return
39+
}
40+
41+
reply.code(200).send({
42+
token: result[0],
43+
expiresIn: result[1]
44+
})
45+
4646
})
4747

4848
server.patch<{
@@ -56,21 +56,21 @@ export const handleAuthRoutes = (
5656
schema: ChangePasswordSchema,
5757
preHandler: authenticate
5858
}, async (request, reply) => {
59-
const passwords = request.body
60-
const payload = extractJwtPayload(
61-
extractToken(request)
62-
)
63-
const state = await authService.changePassword(
64-
payload.login,
65-
passwords.oldPassword,
66-
passwords.newPassword
67-
)
68-
if (isException(state)) {
69-
reply.code(state.statusCode).send(state)
70-
return
71-
}
72-
73-
reply.code(200).send(state)
59+
const passwords = request.body
60+
const payload = extractJwtPayload(
61+
extractToken(request)
62+
)
63+
const state = await authService.changePassword(
64+
payload.login,
65+
passwords.oldPassword,
66+
passwords.newPassword
67+
)
68+
if (isException(state)) {
69+
reply.code(state.statusCode).send(state)
70+
return
71+
}
72+
73+
reply.code(200).send(state)
7474

7575
})
7676
}

source/api/v1/handlers/NotesHandlers.ts

Lines changed: 111 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,21 @@ export const handleNoteRoutes = (
2929
schema: CreateNoteSchema,
3030
preHandler: authenticate
3131
}, async (request, reply) => {
32-
const payload = extractJwtPayload(
33-
extractToken(request)
34-
)
35-
36-
const insertData = {
37-
...request.body,
38-
author: payload.login
39-
}
40-
const createdNote = await notesService.createNote(insertData)
41-
if (isException(createdNote)) {
42-
reply.code(createdNote.statusCode).send(createdNote)
43-
return
44-
}
32+
const payload = extractJwtPayload(
33+
extractToken(request)
34+
)
35+
36+
const insertData = {
37+
...request.body,
38+
author: payload.login
39+
}
40+
const createdNote = await notesService.createNote(insertData)
41+
if (isException(createdNote)) {
42+
reply.code(createdNote.statusCode).send(createdNote)
43+
return
44+
}
4545

46-
reply.code(201).send(createdNote)
46+
reply.code(201).send(createdNote)
4747

4848
})
4949

@@ -64,22 +64,22 @@ export const handleNoteRoutes = (
6464
preHandler: authenticate
6565
},
6666
async (request, reply) => {
67-
const payload = extractJwtPayload(
68-
extractToken(request)
69-
)
67+
const payload = extractJwtPayload(
68+
extractToken(request)
69+
)
7070

71-
const limit = request.query.limit
72-
const skip = request.query.offset
73-
const sort = request.query.sort
74-
const tags = request.query.tags
71+
const limit = request.query.limit
72+
const skip = request.query.offset
73+
const sort = request.query.sort
74+
const tags = request.query.tags
7575

76-
const notes = await notesService.getMyNotes(payload.login, tags, limit, skip, sort)
77-
if (isException(notes)) {
78-
reply.code(notes.statusCode).send(notes)
79-
return
80-
}
76+
const notes = await notesService.getMyNotes(payload.login, tags, limit, skip, sort)
77+
if (isException(notes)) {
78+
reply.code(notes.statusCode).send(notes)
79+
return
80+
}
8181

82-
reply.code(200).send(notes)
82+
reply.code(200).send(notes)
8383

8484
})
8585

@@ -98,21 +98,21 @@ export const handleNoteRoutes = (
9898
schema: GetNotesSchema,
9999
preHandler: authenticate
100100
}, async (request, reply) => {
101-
const payload = extractJwtPayload(
102-
extractToken(request)
103-
)
101+
const payload = extractJwtPayload(
102+
extractToken(request)
103+
)
104104

105-
const limit = request.query.limit
106-
const skip = request.query.offset
107-
const sort = request.query.sort
108-
const tags = request.query.tags
105+
const limit = request.query.limit
106+
const skip = request.query.offset
107+
const sort = request.query.sort
108+
const tags = request.query.tags
109109

110-
const notes = await notesService.getCollaboratedNotes(payload.login, tags, limit, skip, sort)
111-
if (isException(notes)) {
112-
reply.code(notes.statusCode).send(notes)
113-
return
114-
}
115-
reply.code(200).send(notes)
110+
const notes = await notesService.getCollaboratedNotes(payload.login, tags, limit, skip, sort)
111+
if (isException(notes)) {
112+
reply.code(notes.statusCode).send(notes)
113+
return
114+
}
115+
reply.code(200).send(notes)
116116
})
117117

118118
server.get<{
@@ -128,18 +128,18 @@ export const handleNoteRoutes = (
128128
preHandler: authenticate
129129
},
130130
async (request, reply) => {
131-
const payload = extractJwtPayload(
132-
extractToken(request)
133-
)
131+
const payload = extractJwtPayload(
132+
extractToken(request)
133+
)
134134

135-
const id = request.params.id
135+
const id = request.params.id
136136

137-
const foundNote = await notesService.getNote(id, payload.login)
138-
if (isException(foundNote)) {
139-
reply.code(foundNote.statusCode).send(foundNote)
140-
return
141-
}
142-
reply.code(200).send(foundNote)
137+
const foundNote = await notesService.getNote(id, payload.login)
138+
if (isException(foundNote)) {
139+
reply.code(foundNote.statusCode).send(foundNote)
140+
return
141+
}
142+
reply.code(200).send(foundNote)
143143

144144
})
145145

@@ -156,18 +156,18 @@ export const handleNoteRoutes = (
156156
preHandler: authenticate
157157
},
158158
async (request, reply) => {
159-
const payload = extractJwtPayload(
160-
extractToken(request)
161-
)
159+
const payload = extractJwtPayload(
160+
extractToken(request)
161+
)
162162

163-
const id = request.params.id
163+
const id = request.params.id
164164

165-
const state = await notesService.deleteNote(id, payload.login)
166-
if (isException(state)) {
167-
reply.code(state.statusCode).send(state)
168-
return
169-
}
170-
reply.code(200).send(state)
165+
const state = await notesService.deleteNote(id, payload.login)
166+
if (isException(state)) {
167+
reply.code(state.statusCode).send(state)
168+
return
169+
}
170+
reply.code(200).send(state)
171171

172172
})
173173

@@ -183,20 +183,20 @@ export const handleNoteRoutes = (
183183
schema: UpdateNoteSchema,
184184
preHandler: authenticate
185185
}, async (request, reply) => {
186-
const payload = extractJwtPayload(
187-
extractToken(request)
188-
)
186+
const payload = extractJwtPayload(
187+
extractToken(request)
188+
)
189189

190-
const id = request.params.id
191-
const updateData = request.body
190+
const id = request.params.id
191+
const updateData = request.body
192192

193-
const updatedNote = await notesService.updateNote(id, payload.login, updateData)
194-
if (isException(updatedNote)) {
195-
reply.code(updatedNote.statusCode).send(updatedNote)
196-
return
197-
}
193+
const updatedNote = await notesService.updateNote(id, payload.login, updateData)
194+
if (isException(updatedNote)) {
195+
reply.code(updatedNote.statusCode).send(updatedNote)
196+
return
197+
}
198198

199-
reply.code(200).send(updatedNote)
199+
reply.code(200).send(updatedNote)
200200

201201
})
202202

@@ -211,16 +211,16 @@ export const handleNoteRoutes = (
211211
schema: GetNoteCollaboratorsSchema,
212212
preHandler: authenticate
213213
}, async (request, reply) => {
214-
const payload = extractJwtPayload(
215-
extractToken(request)
216-
)
217-
const id = request.params.id
218-
const collaborators = await notesService.getCollaborators(id, payload.login)
219-
if (isException(collaborators)) {
220-
reply.code(collaborators.statusCode).send(collaborators)
221-
return
222-
}
223-
reply.code(200).send(collaborators)
214+
const payload = extractJwtPayload(
215+
extractToken(request)
216+
)
217+
const id = request.params.id
218+
const collaborators = await notesService.getCollaborators(id, payload.login)
219+
if (isException(collaborators)) {
220+
reply.code(collaborators.statusCode).send(collaborators)
221+
return
222+
}
223+
reply.code(200).send(collaborators)
224224

225225
})
226226

@@ -240,24 +240,24 @@ export const handleNoteRoutes = (
240240
schema: AddCollaboratorSchema,
241241
preHandler: authenticate
242242
}, async (request, reply) => {
243-
const payload = extractJwtPayload(
244-
extractToken(request)
245-
)
243+
const payload = extractJwtPayload(
244+
extractToken(request)
245+
)
246246

247-
const id = request.params.id
248-
const collaboratorLogin = request.body.collaboratorLogin
247+
const id = request.params.id
248+
const collaboratorLogin = request.body.collaboratorLogin
249249

250-
const state = await notesService.addCollaborator(
251-
id,
252-
payload.login,
253-
collaboratorLogin
254-
)
255-
if (isException(state)) {
256-
reply.code(state.statusCode).send(state)
257-
return
258-
}
250+
const state = await notesService.addCollaborator(
251+
id,
252+
payload.login,
253+
collaboratorLogin
254+
)
255+
if (isException(state)) {
256+
reply.code(state.statusCode).send(state)
257+
return
258+
}
259259

260-
reply.code(201).send(state)
260+
reply.code(201).send(state)
261261
})
262262

263263
server.delete<{
@@ -275,24 +275,24 @@ export const handleNoteRoutes = (
275275
schema: RemoveCollaboratorSchema,
276276
preHandler: authenticate
277277
}, async (request, reply) => {
278-
const payload = extractJwtPayload(
279-
extractToken(request)
280-
)
278+
const payload = extractJwtPayload(
279+
extractToken(request)
280+
)
281281

282-
const id = request.params.id
283-
const collaboratorLogin = request.body.collaboratorLogin
282+
const id = request.params.id
283+
const collaboratorLogin = request.body.collaboratorLogin
284284

285-
const state = await notesService.removeCollaborator(
286-
id,
287-
payload.login,
288-
collaboratorLogin
289-
)
290-
if (isException(state)) {
291-
reply.code(state.statusCode).send(state)
292-
return
293-
}
285+
const state = await notesService.removeCollaborator(
286+
id,
287+
payload.login,
288+
collaboratorLogin
289+
)
290+
if (isException(state)) {
291+
reply.code(state.statusCode).send(state)
292+
return
293+
}
294294

295-
reply.code(200).send(state)
295+
reply.code(200).send(state)
296296

297297
})
298298
}

0 commit comments

Comments
 (0)