@@ -18,7 +18,7 @@ router.use((req, res, next) => {
1818 next ( )
1919} )
2020
21- router . get ( '/info' , async ( req , res ) => {
21+ router . get ( '/abstracts- info' , async ( req , res ) => {
2222 try {
2323 const o = {
2424 map : function ( ) {
@@ -41,20 +41,20 @@ router.get('/info', async (req, res) => {
4141 . map ( ( { _id, value } ) => ( { flow : _id , courses : JSON . parse ( value ) } ) )
4242
4343 res . json ( { data } )
44- } catch ( e ) {
45- console . error ( e )
46- res . status ( 500 ) . json ( { error : 'Db error' } )
44+ } catch ( err ) {
45+ log . error ( { err } , 'api abstracts-info route' )
46+ res . status ( 500 ) . json ( { error : 'error' } )
4747 }
4848} )
4949
5050router . get ( '/abstracts/:id?' , async ( req , res ) => {
5151 try {
5252 const { id } = req . params
5353 if ( id ) {
54- if ( ! mongoose . Types . ObjectId . isValid ( req . params . id ) )
54+ if ( ! mongoose . Types . ObjectId . isValid ( id ) )
5555 return res . status ( 400 ) . json ( { error : 'Invalid id' } )
5656
57- const abstract = await Abstract . findById ( id )
57+ const abstract = await Abstract . findById ( id , '-__v' )
5858 return abstract
5959 ? res . json ( { data : abstract } )
6060 : res . status ( 404 ) . json ( { data : null } )
@@ -78,22 +78,22 @@ router.get('/abstracts/:id?', async (req, res) => {
7878 name : '$name' ,
7979 semester : '$semester' ,
8080 authorId : '$authorId' ,
81+ date : '$date' ,
8182 telegraph_url : '$telegraph_url' ,
8283 telegraph_path : '$telegraph_path' ,
8384 telegraph_title : '$telegraph_title'
84- }
85- } } } ,
85+ } } } } ,
8686 { $project : {
8787 _id : 0 ,
8888 subject : '$_id' ,
8989 abstracts : '$abstracts'
9090 } }
9191 ] )
92- throw new Error ( 'test' )
92+
9393 res . json ( { data } )
9494 } catch ( err ) {
9595 log . error ( { err } , 'api abstracts route' )
96- res . status ( 500 ) . json ( { error : 'Error 500\nШось поломилося ' } )
96+ res . status ( 500 ) . json ( { error : 'error ' } )
9797 }
9898} )
9999
0 commit comments