@@ -48,113 +48,113 @@ function pack(promise: Promise<any>, res: any | undefined, next: any | undefined
4848}
4949
5050/*** User/session/general info ***/
51- router . get ( '/info' , ( req , res , next ) => {
52- pack ( userInfo ( req ) , res , next ) ;
51+ router . get ( '/info' , async ( req , res , next ) => {
52+ await pack ( userInfo ( req ) , res , next ) ;
5353} ) ;
5454
5555/*** Projects ***/
5656
5757/**
5858 * List all projects filtered by access.
5959 */
60- router . get ( '/projects' , ( req , res , next ) => {
61- pack ( projectAPI . searchProjects ( req ) , res , next ) ;
60+ router . get ( '/projects' , async ( req , res , next ) => {
61+ await pack ( projectAPI . searchProjects ( req ) , res , next ) ;
6262} ) ;
6363
6464/**
6565 * Create a new project.
6666 */
67- router . post ( '/projects/new' , projectValidators . createProject , ( req , res , next ) => {
68- pack ( projectAPI . createProject ( req , req . body ) , res , next ) ;
67+ router . post ( '/projects/new' , projectValidators . createProject , async ( req , res , next ) => {
68+ await pack ( projectAPI . createProject ( req , req . body ) , res , next ) ;
6969} ) ;
7070
7171/**
7272 * Get a particular project.
7373 */
74- router . get ( '/projects/:projectId' , ( req , res , next ) => {
75- pack ( projectAPI . getProject ( req , req . params . projectId ) , res , next ) ;
74+ router . get ( '/projects/:projectId' , async ( req , res , next ) => {
75+ await pack ( projectAPI . getProject ( req , req . params . projectId ) , res , next ) ;
7676} ) ;
7777
7878/**
7979 * Edit a project's basic details.
8080 */
81- router . patch ( '/projects/:projectId' , projectValidators . patchProject , ( req , res , next ) => {
82- pack ( projectAPI . patchProject ( req , req . params . projectId , req . body ) , res , next ) ;
81+ router . patch ( '/projects/:projectId' , projectValidators . patchProject , async ( req , res , next ) => {
82+ await pack ( projectAPI . patchProject ( req , req . params . projectId , req . body ) , res , next ) ;
8383} ) ;
8484
8585/**
8686 * Attach a package to a project, optionally creating or updating the package.
8787 */
88- router . post ( '/projects/:projectId/attach' , projectValidators . attachPackage , ( req , res , next ) => {
89- pack ( projectAPI . attachPackage ( req , req . params . projectId , req . body ) , res , next ) ;
88+ router . post ( '/projects/:projectId/attach' , projectValidators . attachPackage , async ( req , res , next ) => {
89+ await pack ( projectAPI . attachPackage ( req , req . params . projectId , req . body ) , res , next ) ;
9090} ) ;
9191
9292/**
9393 * Detach a package from a project.
9494 */
95- router . post ( '/projects/:projectId/detach' , ( req , res , next ) => {
96- pack ( projectAPI . detachPackage ( req , req . params . projectId , req . body . packageId ) , res , next ) ;
95+ router . post ( '/projects/:projectId/detach' , async ( req , res , next ) => {
96+ await pack ( projectAPI . detachPackage ( req , req . params . projectId , req . body . packageId ) , res , next ) ;
9797} ) ;
9898
9999/**
100100 * Replace a package instance with another, without changing the usage.
101101 */
102- router . post ( '/projects/:projectId/replace' , projectValidators . replacePackage , ( req , res , next ) => {
103- pack ( projectAPI . replacePackage ( req , req . params . projectId , req . body . oldId , req . body . newId ) , res , next ) ;
102+ router . post ( '/projects/:projectId/replace' , projectValidators . replacePackage , async ( req , res , next ) => {
103+ await pack ( projectAPI . replacePackage ( req , req . params . projectId , req . body . oldId , req . body . newId ) , res , next ) ;
104104} ) ;
105105
106106/**
107107 * Build an attribution document. Return the document along
108108 * with any warnings.
109109 */
110- router . get ( '/projects/:projectId/build' , ( req , res , next ) => {
111- pack ( projectAPI . generateAttributionDocument ( req , req . params . projectId ) , res , next ) ;
110+ router . get ( '/projects/:projectId/build' , async ( req , res , next ) => {
111+ await pack ( projectAPI . generateAttributionDocument ( req , req . params . projectId ) , res , next ) ;
112112} ) ;
113113
114114/**
115115 * Building a document using POST will trigger a store & download.
116116 */
117- router . post ( '/projects/:projectId/build' , ( req , res , next ) => {
118- pack ( projectAPI . generateAttributionDocument ( req , req . params . projectId , true ) , res , next ) ;
117+ router . post ( '/projects/:projectId/build' , async ( req , res , next ) => {
118+ await pack ( projectAPI . generateAttributionDocument ( req , req . params . projectId , true ) , res , next ) ;
119119} ) ;
120120
121121/*** Packages ***/
122122
123123/**
124124 * Search all packages by name/version.
125125 */
126- router . post ( '/packages/' , ( req , res , next ) => {
127- pack ( packageAPI . searchPackages ( req , req . body . query ) , res , next ) ;
126+ router . post ( '/packages/' , async ( req , res , next ) => {
127+ await pack ( packageAPI . searchPackages ( req , req . body . query ) , res , next ) ;
128128} ) ;
129129
130130/**
131131 * Admin action: fetch the package verification queue.
132132 */
133- router . get ( '/packages/verification' , ( req , res , next ) => {
134- pack ( packageAPI . getVerificationQueue ( req ) , res , next ) ;
133+ router . get ( '/packages/verification' , async ( req , res , next ) => {
134+ await pack ( packageAPI . getVerificationQueue ( req ) , res , next ) ;
135135} ) ;
136136
137137/**
138138 * Get a single package.
139139 */
140- router . get ( '/packages/:packageId' , ( req , res , next ) => {
141- pack ( packageAPI . getPackage ( req , req . params . packageId , req . query . extended != null ) , res , next ) ;
140+ router . get ( '/packages/:packageId' , async ( req , res , next ) => {
141+ await pack ( packageAPI . getPackage ( req , req . params . packageId , req . query . extended != null ) , res , next ) ;
142142} ) ;
143143
144144/**
145145 * Verify (accept/reject with comments) a single package.
146146 */
147- router . post ( '/packages/:packageId/verify' , ( req , res , next ) => {
148- pack ( packageAPI . verifyPackage ( req , req . params . packageId , req . body . verified , req . body . comments ) , res , next ) ;
147+ router . post ( '/packages/:packageId/verify' , async ( req , res , next ) => {
148+ await pack ( packageAPI . verifyPackage ( req , req . params . packageId , req . body . verified , req . body . comments ) , res , next ) ;
149149} ) ;
150150
151151/*** Licenses ***/
152152
153153/**
154154 * Retrieve all license and tag data.
155155 */
156- router . get ( '/licenses/' , ( req , res , next ) => {
157- pack ( licenseAPI . listLicenses ( ) , res , next ) ;
156+ router . get ( '/licenses/' , async ( req , res , next ) => {
157+ await pack ( licenseAPI . listLicenses ( ) , res , next ) ;
158158} ) ;
159159
160160// error handling for all of the above
0 commit comments