@@ -16,6 +16,7 @@ router.get("/", async (req, res) => {
1616 . json ( { message : 'Error fetching proposals: ' + formatQueryErrorResponse ( e ) } )
1717 }
1818
19+ console . log ( e )
1920 return res . status ( 500 ) . json ( { message : 'Server Error' } )
2021 }
2122} ) ;
@@ -29,9 +30,9 @@ router.post("/", async (req, res) => {
2930
3031 try {
3132 const proposal = await ProposalsService . store ( data ) ;
32- console . log ( "Created Proposal" , JSON . stringify ( proposal ) ) ;
3333 return res . status ( 201 ) . json ( { success : true , proposal : JSON . stringify ( proposal ) } ) ;
3434 } catch ( e ) {
35+ console . log ( e )
3536 return res . status ( 500 ) . json ( { message : 'Server Error' } )
3637 }
3738} ) ;
@@ -42,6 +43,7 @@ router.get("/:id", async (req, res) => {
4243 const proposal = await ProposalsService . show ( id ) ;
4344 return res . status ( 200 ) . json ( proposal ) ;
4445 } catch ( e ) {
46+ console . log ( e )
4547 return res . status ( 500 ) . json ( { message : 'Server Error' } )
4648 }
4749} ) ;
@@ -58,13 +60,20 @@ router.put("/:id", async (req, res) => {
5860 const result = await ProposalsService . update ( id , validationResult . data ) ;
5961 res . status ( 200 ) . json ( result ) ;
6062 } catch ( e ) {
63+ console . log ( e )
6164 return res . status ( 500 ) . json ( { message : 'Server Error' } )
6265 }
6366} ) ;
6467
65- router . delete ( "/:id" , ( req , res ) => {
68+ router . delete ( "/:id" , async ( req , res ) => {
6669 const { id } = req . params ;
67- res . status ( 204 ) . json ( ) ; // No Content
70+ try {
71+ const result = await ProposalsService . destroy ( id ) ;
72+ return res . status ( 200 ) . json ( { count : result . rowCount , rows :result . rows } ) ;
73+ } catch ( e ) {
74+ console . log ( e )
75+ return res . status ( 500 ) . json ( { message : 'Server Error' } )
76+ }
6877} ) ;
6978
7079export default router ;
0 commit comments