-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
52 lines (46 loc) · 3.4 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import express from "express"
import { initializeApp } from "firebase/app"
import admin from "firebase-admin"
import NotFound from "./errors/notFound.js"
import dotenv from "dotenv"
import cors from "cors"
import customerRouter from "./routes/customerRoutes.js"
import orderRouter from "./routes/orderRoutes.js"
import deliveryPartnerRouter from "./routes/deliveryPartnerRouter.js"
import adminRouter from "./routes/adminRoutes.js"
import errorHandler from "./middleware/errorHandler.js"
dotenv.config()
const firebaseConfig = JSON.parse(process.env.FIREBASE_API_KEY)
initializeApp(firebaseConfig)
admin.initializeApp({
credential: admin.credential.cert({
type: "service_account",
project_id: "b2c-main",
private_key_id: "19aeea50cf6376c66ed6d542062b90d307a0d923",
private_key:
"-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDLjZ9M9qUbwadU\ns8Zxk90Mo6YjUIJwwhJuUBSFKBYgu4LAwCvdo7Zrvnwpc1YRBCYnuPLLzrY92zl8\n1nK+mk1rL9efT0Zu5H6fTI7a6GFsSMIrh0IFBlE1bAhxrpkXFq2IEsEj9HcLqim/\n50giNVd9wYS1TGChDLo6HIku5zF9UAZBT6slXNExA3cTglNoagoVCv/z6zi5QJMT\nwV97sjHyBjrYVyxmoB/FxahuGUNZt5CbKhH72PoUjBoeY+ziGiulqxwOp3ZU7pDA\nBaObf+VAlwKcAcEA48/zMgxIZBdG/a/9JvGD1qmjz9R3RmHRhawWTIIQYXsM03MQ\nj04h8p9hAgMBAAECggEABPHIdeOHNt7j3vCvqhCCtQlj9AWKPZu6H6n4poXVJRqD\nmtrpDsJhroI3o8bJ1ZXe0573bmy62m8/NaF8ltV1QaOtewKUr+kDUw7y2oL8qmWJ\nYz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v4yyjJGKB5mHkhes\nOi9DRpVB1/imG22deK1PEYHV\n-----END PRIVATE KEY-----\n",
client_email: "[email protected]",
client_id: "108416560128203101015",
auth_uri: "https://accounts.google.com/o/oauth2/auth",
token_uri: "https://oauth2.googleapis.com/token",
auth_provider_x509_cert_url: "https://www.googleapis.com/oauth2/v1/certs",
client_x509_cert_url:
"https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-hmp97%40b2c-main.iam.gserviceaccount.com",
universe_domain: "googleapis.com"
})
})
const app = express()
app.use(express.json())
app.use(cors())
app.use("/api/v1/customer", customerRouter)
app.use("/api/v1/order", orderRouter)
app.use("/api/v1/deliveryPartner", deliveryPartnerRouter)
app.use("/api/v1/admin", adminRouter)
app.all("*", () => {
throw new NotFound("Invalid route")
})
app.use(errorHandler)
const port = process.env.PORT || 5000
app.listen(port, () => {
console.log(`Server running on port ${port}`)
})