|
| 1 | +import 'reflect-metadata'; |
1 | 2 | import mongoose from 'mongoose';
|
2 | 3 | import MongoDBInterface from '@accounts/mongo';
|
3 |
| -import { DatabaseManager } from '@accounts/database-manager'; |
4 | 4 | import AccountsMagicLink from '@accounts/magic-link';
|
5 | 5 | import { AccountsServer } from '@accounts/server/lib/accounts-server';
|
6 | 6 |
|
7 | 7 | const start = async () => {
|
8 |
| - await mongoose.connect('mongodb://localhost:27017/accounts-js-magic-link-example', { |
9 |
| - useNewUrlParser: true, |
10 |
| - }); |
| 8 | + await mongoose.connect('mongodb://localhost:27017/accounts-js-magic-link-example'); |
11 | 9 | const mongoConn = mongoose.connection;
|
12 | 10 |
|
13 | 11 | // Build a storage for storing users
|
14 | 12 | const userStorage = new MongoDBInterface(mongoConn);
|
15 |
| - // Create database manager (create user, find users, sessions etc) for accounts-js |
16 |
| - const accountsDb = new DatabaseManager({ |
17 |
| - sessionStorage: userStorage, |
18 |
| - userStorage, |
19 |
| - }); |
20 | 13 |
|
21 | 14 | const accountsMagicLink = new AccountsMagicLink({});
|
22 | 15 |
|
23 | 16 | // Create accounts server that holds a lower level of all accounts operations
|
24 | 17 | // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
25 | 18 | const accountsServer = new AccountsServer(
|
26 |
| - { db: accountsDb, tokenSecret: 'secret' }, |
| 19 | + { |
| 20 | + tokenSecret: 'secret', |
| 21 | + }, |
27 | 22 | {
|
28 | 23 | magicLink: accountsMagicLink,
|
29 |
| - } |
| 24 | + }, |
| 25 | + new MongoDBInterface(mongoConn) |
30 | 26 | );
|
31 | 27 |
|
32 | 28 | // Setup a user (or use one from a previous run)
|
|
0 commit comments