Skip to content
On this page

@semantic-api/server

Global API

init

Setups a HTTP server that will put the API running. This function receives an ApiConfig as an optional parameter and resolves an Hapi.Server object.

ts
declare const init: async (_apiConfig?: ApiConfig): Promise<Hapi.Server>

initThenStart shorthand

This shorthand function will setup the HTTP server and start it immediately.

ts
export const initThenStart = async (...args: Parameters<typeof init>) => {
  const server = await init(...args)
  server.start()
}

initWithDatabase shorthand

This shorthand function will setup the HTTP server and call connectToDatabase immediately.

ts
export const initWithDatabase = async (...args: Parameters<typeof init>) => {
  await connectDatabase()
  return init(...args)
}

initWithDatabaseThenStart shorthand

This shorthand function will setup the HTTP server and connect to the database and start immediately.

ts
export const initWithDatabaseThenStart = async (...args: Parameters<typeof init>) => {
  const server = await initWithDatabase(...args)
  server.start()
}

Last updated: