-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrouter.ts
73 lines (59 loc) · 2.09 KB
/
router.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { Router } from "./deps.ts";
import {UserController} from './controller/user.ts'
// import {ElectionController} from '../../controller/election.ts'
import {CommunityController} from './controller/community.ts'
import { authourized } from "./middleware/isAuth.ts";
import { AdminController } from "./controller/admin.ts";
const router = new Router();
const us = new UserController
// const ec = new ElectionController
const cc = new CommunityController
const ac = new AdminController
const signIn = us.signInUser
const signUp = us.createUser
const getUsers = us.getUsers
const getUser = us.getUser
const currentUser = us.currentUser
const updateUserById = us.updateUserById
// const getUserById = us.getUserById
//Election controllers
// const newElection = ec.newElection
// const addCandidate = ec.addCandidate
// const getElection = ec.getElection
// const toggleElection = ec.toggleElection
// const userVote = ec.userVote
//Communiity Controllers
const newCommunity = cc.newCommunity
const getCommunity = cc.getCommunities
const getCommunityByID = cc.getCommunityByID
// const getMemberCount = cc.getMemberCount
const newCommunityChat = cc.newCommunityChat
const ws = cc.createWs
// const getUserCommunity = cc.getUserCommunity
// const userJoinCommunity = cc.userJoinCommunity
// User routes
router
.POST("/auth/signin", signIn)
.POST("/auth/signup", signUp)
.GET("/users", getUsers)
.POST("/user/:id", getUser)
.PUT("/user/update", updateUserById)
.GET("/user/:id", getUser)
.GET('/user', currentUser)
.GET('/user/announcements', currentUser)
router
.POST("/community/new", newCommunity)
.POST("/community/:id", getCommunityByID)
.GET("/communities", getCommunity)
.POST("/community/sendchat", newCommunityChat)
.POST("/ws", ws)
.GET('/', (context: { response: { body: string; }; }) => {
context.response.body = 'Server is listerning on 3000';
});
//admin requests
router
.POST()
// router
// .GET("user/:username",authourized, getUserByusername)
// .patch("user/:id",authourized, updateUserById)
export default router