@@ -35,7 +35,7 @@ const router = express.Router();
3535router . get ( "/" , async ( req , res ) => {
3636 // metrics.increment("endpoint.admin.users.get");
3737 const dbUsers = await db . query . users . findMany ( ) ;
38- res . status ( 200 ) . json ( dbUsers ) ;
38+ return res . status ( 200 ) . json ( dbUsers ) ;
3939} ) ;
4040
4141/**
@@ -83,7 +83,7 @@ router.get("/user/:id", async (req, res) => {
8383 } ) ;
8484 }
8585
86- res . status ( 200 ) . json ( dbUser ) ;
86+ return res . status ( 200 ) . json ( dbUser ) ;
8787 } catch ( error ) {
8888 logger . error ( error as string ) ;
8989
@@ -132,11 +132,11 @@ router.patch("/user/:id", async (req, res) => {
132132 . set ( updateData )
133133 . where ( eq ( users . id , parseInt ( id ) ) ) ;
134134
135- res . status ( 200 ) . json ( {
135+ return res . status ( 200 ) . json ( {
136136 message : "User updated successfully." ,
137137 } ) ;
138138 } catch ( error ) {
139- res . status ( 500 ) . json ( {
139+ return res . status ( 500 ) . json ( {
140140 message : "An error occurred." ,
141141 } ) ;
142142 }
@@ -167,10 +167,9 @@ router.post("/user/new", async (req, res) => {
167167 const { name, email, password } = body ;
168168
169169 if ( ! name || ! email || ! password ) {
170- res
170+ return res
171171 . status ( 400 )
172172 . json ( "Invalid arguments. Please provide name, email, and password" ) ;
173- return ;
174173 }
175174
176175 // Check if the user already exists
@@ -179,8 +178,7 @@ router.post("/user/new", async (req, res) => {
179178 } ) ;
180179
181180 if ( user ) {
182- res . status ( 400 ) . json ( "User with that email already exists" ) ;
183- return ;
181+ return res . status ( 400 ) . json ( "User with that email already exists" ) ;
184182 }
185183
186184 const salt = bcrypt . genSaltSync ( saltRounds ) ;
@@ -197,7 +195,7 @@ router.post("/user/new", async (req, res) => {
197195 } )
198196 . returning ( ) ;
199197
200- res . status ( 200 ) . json ( {
198+ return res . status ( 200 ) . json ( {
201199 message : "User created successfully, please login." ,
202200 uuid : newUser . uuid ,
203201 } ) ;
@@ -228,11 +226,11 @@ router.delete("/user/:id", async (req, res) => {
228226 } )
229227 . where ( eq ( users . id , parseInt ( id ) ) ) ;
230228
231- res . status ( 200 ) . json ( {
229+ return res . status ( 200 ) . json ( {
232230 message : "User deleted successfully." ,
233231 } ) ;
234232 } catch ( error ) {
235- res . status ( 500 ) . json ( {
233+ return res . status ( 500 ) . json ( {
236234 message : "An error occurred." ,
237235 } ) ;
238236 }
@@ -319,11 +317,11 @@ router.patch("/role/:id/:role", async (req, res) => {
319317 } )
320318 . where ( eq ( users . id , parseInt ( id ) ) ) ;
321319
322- res . status ( 200 ) . json ( {
320+ return res . status ( 200 ) . json ( {
323321 message : `User role updated to ${ permission } successfully.` ,
324322 } ) ;
325323 } catch ( error ) {
326- res . status ( 500 ) . json ( {
324+ return res . status ( 500 ) . json ( {
327325 message : "An error occurred." ,
328326 } ) ;
329327 }
@@ -382,11 +380,11 @@ router.patch("/useExtended/:id/:useExtended", async (req, res) => {
382380 } )
383381 . where ( eq ( users . id , parseInt ( id ) ) ) ;
384382
385- res . status ( 200 ) . json ( {
383+ return res . status ( 200 ) . json ( {
386384 message : `User useExtended data updated to ${ useExtended } successfully.` ,
387385 } ) ;
388386 } catch ( error ) {
389- res . status ( 500 ) . json ( {
387+ return res . status ( 500 ) . json ( {
390388 message : "An error occurred." ,
391389 } ) ;
392390 }
0 commit comments