A work in progress repo to get the types for KeystoneJS 5 ready to contribute to Definitely Typed.
To use with your version of Keystone, install the package as a dev dependency:
$ npm i --save-dev keystone-typescript-types
Then set up Typescript so it knows how to find these types by creating or editing the typeRoots value in your tsconfig.json file:
{
"compilerOptions": {
// The rest of your existing
"typeRoots": ["node_modules/keystone-typescript-types/types"]
}
}Since the Keystone CLI doesn't support Typescript, we need to set up a custom server:
// src/index.ts
import express from 'express';
import { Keystone } from '@keystonejs/keystone';
import { PasswordAuthStrategy } from '@keystonejs/auth-password';
import { GraphQLApp } from '@keystonejs/app-graphql';
import { AdminUIApp } from '@keystonejs/app-admin-ui';
import { KnexAdapter as Adapter } from '@keystonejs/adapter-knex';
const keystone = new Keystone({
name: 'Your Project Name',
adapter: new Adapter(),
});
// Create your lists here
const authStrategy = keystone.createAuthStrategy({
type: PasswordAuthStrategy,
list: 'User',
});
const apps = [new GraphQLApp(), new AdminUIApp({ enableDefaultRoute: true, authStrategy })];
keystone
.prepare({ apps, dev: process.env.NODE_ENV !== 'production' })
.then(async ({ middlewares }) => {
await keystone.connect();
const app = express();
app.use(middlewares).listen(3000);
console.log('Keystone is running!');
console.log();
console.log(`π Keystone Admin UI: http://localhost:3000/admin`);
console.log(`π GraphQL Playground: http://localhost:3000/admin/graphiql`);
console.log(`π GraphQL API: http://localhost:3000/admin/api`);
});And we also need to make a change to the scripts in package.json:
{
"scripts": {
"dev": "cross-env NODE_ENV=development DISABLE_LOGGING=true ts-node --files index.ts",
// "build": "cross-env NODE_ENV=production keystone build", TODO, handle admin UI build outside of CLI
"start": "npm run dev"
}
}And you should be good to go.
These are very rough typings. Contributions are welcomed.
- @keystonejs/keystone
- @keystonejs/fields
-
@keystonejs/app-admin-ui
-
@keystonejs/app-next
-
@keystonejs/app-nuxt
-
@keystonejs/app-static
FIELD ADAPTERS -
@keystonejs/file-adapters
-
@keystonejs/oembed-adapters
AUTHENTICATION STRATEGIES -
@keystonejs/auth-password
-
@keystonejs/auth-passport
- @keystonejs/list-plugins
- @keystonejs/apollo-helpers
- @keystonejs/email
- @keystonejs/logger
- @keystonejs/session
- @keystonejs/adapter-knex
- @keystonejs/adapter-mongoose
- Keystone (in progress)
- apps
- admin
- graphql
- nextjs
- nuxtjs
- static app
- plugins (in progress)
- adapters
- apps
- createList
- fields (simple union)
- adapter
- hooks
- Authentication Strategies
- password
- passport
- Access Control
- Query validation
- hooks validation
- Database adapters
- Mongoose Adapter:
- connection
- listAdapterClass
- Knex Adapter
- connection
- listAdapterClass
- Mongoose Adapter:
- List plugins
- File Adapter