Skip to content

Commit

Permalink
add URL examples
Browse files Browse the repository at this point in the history
  • Loading branch information
dcousens committed Mar 26, 2024
1 parent 8f29a56 commit d843039
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions examples/extend-express-app/keystone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ export default config<TypeInfo>({
// this example HTTP GET handler retrieves any posts in the database for your context
// with an optional request query parameter of `draft=1`
// returning them as JSON
//
// e.g
// http://localhost:3000/rest/posts
// http://localhost:3000/rest/posts?draft=1
//
app.get('/rest/posts', async (req, res) => {
const context = await commonContext.withRequest(req, res)
// if (!context.session) return res.status(401).end()
Expand All @@ -46,6 +51,9 @@ export default config<TypeInfo>({
},

extendHttpServer: (server, commonContext) => {
// e.g
// http://localhost:3000/rest/posts/clu7x6ch90002a89s6l63bjb5
//
server.on('request', async (req, res) => {
if (!req.url?.startsWith('/rest/posts/')) return

Expand Down

0 comments on commit d843039

Please sign in to comment.