0.6.9 • Published 3 years ago

@financial-times/tc-api-express v0.6.9

Weekly downloads
134
License
ISC
Repository
github
Last release
3 years ago

@financial-times/tc-api-rest-express

Adds a treecreeper api to an express app. It provides

  • a GraphQL api
  • RESTful CRUD endpoints
  • Takes care of initialising a schema-sdk and api-db-manager, so that data structures automatically update

API

getApp(options)

Returns an express instance with the GraphQL and REST apis set up according to the options provided

A treecreeper object is attached to the express instance with the following properties

response

logger

A reference to treecreeper's internal logger, which decorates each log with useful application/request metadata

isSchemaUpdating

A function that returns a boolean indicating whether the application is successfully keeping the schema that defines its data types up to date

emitter and availableEvents

See tc-api-rest-handlers for details

Options

app

An express app. If none is provided, one will be created

schemaOptions

Options to pass to tc-schema-sdk. Note that some options may be provided via environment variables

treecreeperPath = '/'

The path at which the treecreeper api is served

graphqlPath = '/graphql'

The path, relative to treecreeperPath, where the graphql api is served

graphqlMethods = ['post']

Methods accepted by the graphql api

graphqlMiddlewares = []

Array of middlewares to call before the graphql handler executes

restPath = '/rest'

The path, relative to treecreeperPath, where the REST api is served

restMiddlewares = []

Array of middlewares to call before the relevant REST handler executes

documentStore

An optional reference to a tc-api-s3-document-store instance (or a library implementing the same API), used to store large properties outside the neo4j instance

typeDefs

See the tc-api-graphql README

resolvers

See the tc-api-graphql README

excludeTypes

See the tc-api-graphql README

republishSchema

A boolean indicating whether the application needs to republish the schema to somewhere once it has updated the graphqlApi. Note that republishing depends on a TREECREEPER_SCHEMA_BUCKET envioronment variable, which should be the name of an s3 bucket.

republishSchemaPrefix = 'api'

If the application needs to republish the schema to somewhere once it has updated the graphqlApi, this string indicates the prefix to use

timeout

Optional integer to set maximum time DB will be queried for and, by association, maximum time a request can stay alive for before being rejected and erroring

Example

const { getApp } = require('@financial-times/tc-api-rest-express');
const {
	authorization,
	rateLimiting,
	disableWrites,
} = require('../middlewares');
const PORT = process.env.PORT || 8888;

getApp({
	graphqlMethods: ['post', 'get'],
	graphqlMiddlewares: [authorization, rateLimiting],
	restMiddlewares: [authorization, rateLimiting, disableWrites],
}).then(app => {
	app.listen(PORT, () => {
		app.logger(`Listening on ${PORT}`);
	});
});
0.6.9

3 years ago

0.6.7

3 years ago

0.6.8

3 years ago

0.6.6

3 years ago

0.6.5

3 years ago

0.6.5-beta.1

3 years ago

0.6.4

3 years ago

0.6.3

3 years ago

0.6.2

3 years ago

0.6.1

3 years ago

0.6.0-beta.0

3 years ago

0.5.35

3 years ago

0.5.34

3 years ago

0.5.34-beta.2

3 years ago

0.5.33-beta.1

3 years ago

0.5.32

3 years ago

0.5.33

3 years ago

0.5.30

3 years ago

0.5.31

3 years ago

0.5.32-beta.1

3 years ago

0.5.29

3 years ago

0.5.28

3 years ago

0.5.27

3 years ago

0.5.26

4 years ago

0.5.26-beta.1

4 years ago

0.5.25

4 years ago

0.5.24

4 years ago

0.5.23

4 years ago

0.5.22

4 years ago

0.5.21

4 years ago

0.5.20

4 years ago

0.5.18

4 years ago

0.5.16

4 years ago

0.5.17

4 years ago

0.5.15

4 years ago

0.5.13

4 years ago

0.5.11

4 years ago

0.5.12

4 years ago

0.5.10

4 years ago

0.5.9

4 years ago

0.5.8

4 years ago

0.5.7

4 years ago

0.5.6

4 years ago

0.5.5

4 years ago

0.5.4

4 years ago

0.5.3

4 years ago

0.5.2

4 years ago

0.5.1

4 years ago

0.5.0

4 years ago

0.4.9

4 years ago

0.4.8

4 years ago

0.4.10-beta.1

4 years ago

0.4.7

4 years ago

0.4.6

4 years ago

0.4.5

4 years ago

0.4.4

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.4.0-beta.3

4 years ago

0.4.0-beta.1

4 years ago

0.4.0-beta.2

4 years ago

0.3.11

4 years ago

0.3.10

4 years ago

0.3.9

4 years ago

0.3.8

4 years ago

0.3.6

4 years ago

0.3.7

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.3.2

4 years ago

0.3.3

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.3.0-beta.14

4 years ago

0.3.0-beta.13

4 years ago

0.3.0-beta.12

4 years ago

0.3.0-beta.11

4 years ago

0.3.0-beta.10

4 years ago

0.3.0-beta.8

4 years ago

0.3.0-beta.9

4 years ago

0.3.0-beta.5

4 years ago

0.3.0-beta.3

4 years ago

0.3.0-beta.4

4 years ago

0.3.0-beta.2

4 years ago

0.3.0-beta.1

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.1.2-beta.6

4 years ago

0.2.0

4 years ago

0.1.2-beta.5

4 years ago

0.1.2-beta.2

4 years ago

0.1.2-beta.3

4 years ago

0.1.2-beta.1

4 years ago

0.1.2-beta.4

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago