Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie committed May 7, 2021
1 parent 841d1f4 commit 7cefaff
Showing 1 changed file with 0 additions and 71 deletions.
71 changes: 0 additions & 71 deletions examples/todo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,77 +5,6 @@ It implements a basic task management system, with `Tasks` and `People` who can

You can use this project as a starting place for learning how to use Keystone.

## Feature

This project shows off XYZ.

### Added fields

```typescript
// Added an email and password pair to be used with authentication
// The email address is going to be used as the identity field, so it's
// important that we set both isRequired and isUnique
email: text({ isRequired: true, isUnique: true }),
// The password field stores a hash of the supplied password, and
// we want to ensure that all people have a password set, so we use
// the isRequired flag.
```

### Auth config

```typescript
// createAuth configures signin functionality based on the config below. Note this only implements
// authentication, i.e signing in as an item using identity and secret fields in a list. Session
// management and access control are controlled independently in the main keystone config.
const { withAuth } = createAuth({
// This is the list that contains items people can sign in as
listKey: 'Person',
// The identity field is typically a username or email address
identityField: 'email',
// The secret field must be a password type field
secretField: 'password',

// initFirstItem turns on the "First User" experience, which prompts you to create a new user
// when there are no items in the list yet
initFirstItem: {
// These fields are collected in the "Create First User" form
fields: ['name', 'email', 'password'],
},
});
```

### Session

```typescript
// Stateless sessions will store the listKey and itemId of the signed-in user in a cookie.
// This session object will be made availble on the context object used in hooks, access-control,
// resolvers, etc.
const session = statelessSessions({
// The maxAge option controls how long session cookies are valid for before they expire
maxAge: 60 * 60 * 24 * 30, // 30 days
// The session secret is used to encrypt cookie data (should be an environment variable)
secret: '-- EXAMPLE COOKIE SECRET; CHANGE ME --',
});
```

### Wrapped config

```typescript
// We wrap our config using the withAuth function. This will inject all
// the extra config required to add support for authentication in our system.
export default withAuth(
config({
db: {
provider: 'sqlite',
url: process.env.DATABASE_URL || 'file:./keystone-example.db',
},
lists,
// We add our session configuration to the system here.
session,
})
);
```

## Instructions

To run this project, clone the Keystone repository locally then navigate to this directory and run:
Expand Down

0 comments on commit 7cefaff

Please sign in to comment.