diff --git a/src/index.ts b/src/index.ts index 066e15f..3c190c0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,11 +18,11 @@ app.use(cors()); app.use(express.json()); app.use(passport.initialize()); app.set('port', process.env.PORT || 8001); -app.use('/', authRoutes); -app.use('/', userProfileRoutes); -app.use('/', categoryRoutes); -app.use('/', shelfRoutes); -app.use('/', wordRoutes); +app.use('/auth/', authRoutes); +app.use('/user/', userProfileRoutes); +app.use('/category/', categoryRoutes); +app.use('/shelf/', shelfRoutes); +app.use('/library/', wordRoutes); app.get('/', (request, response) => { response.send('Server running @ port' + app.get('port')); diff --git a/src/user-profile/category-routes.ts b/src/user-profile/category-routes.ts index 531c68c..3cb18bf 100644 --- a/src/user-profile/category-routes.ts +++ b/src/user-profile/category-routes.ts @@ -11,7 +11,7 @@ export const categoryRoutes = express.Router(); export const jwtAuthentication = passport.authenticate('jwt', { session: false }); // Get Category Details -categoryRoutes.get('/category/', jwtAuthentication, async (request, response) => { +categoryRoutes.get('/details/', jwtAuthentication, async (request, response) => { const categoryCollection = getDatabaseClient().db(DB_NAME).collection('categories'); const currentCategory = await categoryCollection.findOne({ @@ -31,7 +31,7 @@ categoryRoutes.get('/category/', jwtAuthentication, async (request, response) => // Add category -categoryRoutes.post('/category/', jwtAuthentication, async (request, response) => { +categoryRoutes.post('/add/', jwtAuthentication, async (request, response) => { const user: MongoUser = (request.user as any); const categoryCollection = getDatabaseClient().db(DB_NAME).collection('categories'); @@ -75,7 +75,7 @@ categoryRoutes.post('/category/', jwtAuthentication, async (request, response) = // Update category -categoryRoutes.put('/category/', jwtAuthentication, async (request, response) => { +categoryRoutes.put('/update/', jwtAuthentication, async (request, response) => { const categoryCollection = getDatabaseClient().db(DB_NAME).collection('categories'); const currentCategory = await categoryCollection.findOne({ @@ -110,7 +110,6 @@ categoryRoutes.put('/category/', jwtAuthentication, async (request, response) => response.sendStatus(200); } catch (e) { - console.log(e); response.status(400); response.send(e.toString()); } diff --git a/src/user-profile/shelf-routes.ts b/src/user-profile/shelf-routes.ts index ce61c2a..14c0239 100644 --- a/src/user-profile/shelf-routes.ts +++ b/src/user-profile/shelf-routes.ts @@ -12,7 +12,7 @@ export const jwtAuthentication = passport.authenticate('jwt', { session: false } // GET shelf details -shelfRoutes.get('/shelf/', jwtAuthentication, async (request, response) => { +shelfRoutes.get('/details/', jwtAuthentication, async (request, response) => { const shelfCollection = getDatabaseClient().db(DB_NAME).collection('shelves'); const currentShelf = await shelfCollection.findOne({ @@ -32,7 +32,7 @@ shelfRoutes.get('/shelf/', jwtAuthentication, async (request, response) => { // Add shelf -shelfRoutes.post('/shelf/', jwtAuthentication, async (request, response) => { +shelfRoutes.post('/add/', jwtAuthentication, async (request, response) => { const categoryCollection = getDatabaseClient().db(DB_NAME).collection('categories'); const shelfCollection = getDatabaseClient().db(DB_NAME).collection('shelves'); @@ -94,10 +94,8 @@ shelfRoutes.post('/shelf/', jwtAuthentication, async (request, response) => { return; }); - - // Update shelf -shelfRoutes.put('/shelf/', jwtAuthentication, async (request, response) => { +shelfRoutes.put('/update/', jwtAuthentication, async (request, response) => { const shelfCollection = getDatabaseClient().db(DB_NAME).collection('shelves'); const currentShelf = await shelfCollection.findOne({ @@ -131,7 +129,6 @@ shelfRoutes.put('/shelf/', jwtAuthentication, async (request, response) => { response.sendStatus(200); } catch (e) { - console.log(e); response.status(400); response.send(e.toString()); } diff --git a/src/user-profile/word-routes.ts b/src/user-profile/word-routes.ts index 8b5adef..79d735a 100644 --- a/src/user-profile/word-routes.ts +++ b/src/user-profile/word-routes.ts @@ -9,7 +9,7 @@ export const jwtAuthentication = passport.authenticate('jwt', { session: false } // Get All Words -wordRoutes.get('/all-words/', jwtAuthentication, async (request, response) => { +wordRoutes.get('/all/', jwtAuthentication, async (request, response) => { const wordCollection = getDatabaseClient().db(DB_NAME).collection('words'); const allWords = await wordCollection.find().toArray(); @@ -20,7 +20,7 @@ wordRoutes.get('/all-words/', jwtAuthentication, async (request, response) => { return; }); -wordRoutes.get('/word/', jwtAuthentication, async (request, response) => { +wordRoutes.get('/search/', jwtAuthentication, async (request, response) => { const wordCollection = getDatabaseClient().db(DB_NAME).collection('words'); if (!request.body.name) { @@ -39,7 +39,7 @@ wordRoutes.get('/word/', jwtAuthentication, async (request, response) => { return; }); -wordRoutes.post('/word/', jwtAuthentication, async (request, response) => { +wordRoutes.post('/add/', jwtAuthentication, async (request, response) => { const wordCollection = getDatabaseClient().db(DB_NAME).collection('words'); if (!request.body.name || request.body.grammaticalDetails) {