File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -90,9 +90,14 @@ export function register(server) {
90
90
91
91
server . get ( '/api/v1/crates/:crate_id/:version_num/downloads' , function ( schema , request ) {
92
92
let crateId = request . params . crate_id ;
93
+ let crate = schema . crates . find ( crateId ) ;
94
+ if ( ! crate ) return notFound ( ) ;
95
+
93
96
let versionNum = request . params . version_num ;
94
- let versionId = schema . versions . findBy ( { crate : crateId , num : versionNum } ) . id ;
95
- return schema . versionDownloads . where ( { version : versionId } ) ;
97
+ let version = schema . versions . findBy ( { crate : crateId , num : versionNum } ) ;
98
+ if ( ! version ) return { errors : [ { detail : `crate \`${ crateId } \` does not have a version \`${ versionNum } \`` } ] } ;
99
+
100
+ return schema . versionDownloads . where ( { version : version . id } ) ;
96
101
} ) ;
97
102
98
103
server . get ( '/api/v1/crates/:crate_id/owner_user' , function ( schema , request ) {
You can’t perform that action at this time.
0 commit comments