-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✨ API: Add HttpServer entrypoint
- Loading branch information
1 parent
f58da8c
commit 72df6d0
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* eslint-disable header/header */ | ||
import { default as cors } from 'cors'; | ||
import express from 'express'; | ||
|
||
import * as config from './config.js'; | ||
import log from './log.js'; | ||
import { arIoRouter } from './routes/ar-io.js'; | ||
import { arnsRouter } from './routes/arns.js'; | ||
import { dataRouter } from './routes/data/index.js'; | ||
import { apolloServer } from './routes/graphql/index.js'; | ||
import { openApiRouter } from './routes/openapi.js'; | ||
import * as system from './system.js'; | ||
|
||
const app = express(); | ||
|
||
app.use( | ||
cors({ | ||
exposedHeaders: ['X-ArNS-Resolved-Id', 'X-ArNS-TTL-Seconds'], | ||
}), | ||
); | ||
|
||
app.use(arnsRouter); | ||
app.use(openApiRouter); | ||
app.use(arIoRouter); | ||
app.use(dataRouter); | ||
|
||
// GraphQL | ||
const apolloServerInstanceGql = apolloServer(system.db, { | ||
introspection: true, | ||
persistedQueries: false, | ||
}); | ||
apolloServerInstanceGql.start().then(() => { | ||
apolloServerInstanceGql.applyMiddleware({ | ||
app, | ||
path: '/graphql', | ||
}); | ||
app.listen(config.PORT, () => { | ||
log.info(`Listening on port ${config.PORT}`); | ||
}); | ||
}); |