@@ -5,7 +5,6 @@ import * as admin from "firebase-admin";
55import { ApolloServer } from "apollo-server-express" ;
66import { sequelize } from "./models" ;
77import schema from "./graphql" ;
8- import Application from "./models/application.model" ;
98import memeberData from "./graphql/sampleData/members.json" ;
109import firebaseAuthUsers from "./graphql/sampleData/users.json" ;
1110
@@ -112,52 +111,6 @@ app.get("/authUsers", async (req, res) => {
112111 }
113112} ) ;
114113
115- app . get ( "/termApplications" , async ( req , res ) => {
116- ref
117- . orderByChild ( "term" )
118- . equalTo ( "Fall 2023" ) // Fetch all applications for <term> (e.g. Fall 2023)
119- // eslint-disable-next-line func-names
120- . once ( "value" , function ( snapshot ) {
121- const applications : Application [ ] = [ ] ;
122- snapshot . forEach ( ( childSnapshot ) => {
123- applications . push ( childSnapshot . val ( ) ) ;
124- } ) ;
125- res . status ( 200 ) . json ( applications ) ;
126- } ) ;
127- } ) ;
128-
129- app . get ( "/applications" , async ( req , res ) => {
130- try {
131- const snapshot = await ref . once ( "value" ) ;
132- const applications : Application [ ] = [ ] ;
133- snapshot . forEach ( ( childSnapshot ) => {
134- applications . push ( childSnapshot . val ( ) ) ;
135- } ) ;
136- res . status ( 200 ) . json ( applications ) ;
137- } catch ( error ) {
138- res
139- . status ( 500 )
140- . send ( "An error occurred while retrieving the applications." ) ;
141- }
142- } ) ;
143-
144- app . get ( "/applications/:id" , async ( req , res ) => {
145- try {
146- const { id } = req . params ;
147- const snapshot = await ref . child ( id ) . once ( "value" ) ;
148- const application = snapshot . val ( ) ;
149- if ( application ) {
150- res . status ( 200 ) . json ( application ) ;
151- } else {
152- res . status ( 404 ) . send ( "Student application not found." ) ;
153- }
154- } catch ( error ) {
155- res
156- . status ( 500 )
157- . send ( "An error occurred while retrieving the student application." ) ;
158- }
159- } ) ;
160-
161114app . listen ( { port : process . env . PORT || 5000 } , ( ) => {
162115 // eslint-disable-next-line no-console
163116 console . info ( `Server is listening on port ${ process . env . PORT || 5000 } !` ) ;
0 commit comments