Skip to content

Commit

Permalink
remove MongoDB
Browse files Browse the repository at this point in the history
This will be moved to a separate repo.
  • Loading branch information
nicolodavis committed Mar 18, 2020
1 parent 15388af commit 7b70cab
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 392 deletions.
94 changes: 0 additions & 94 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@
"jest": "^24.0.0",
"jest-transform-svelte": "^2.1.0",
"lint-staged": "^8.1.0",
"mongo-mock": "^3.3.2",
"mongodb": "^3.0.3",
"node-persist": "^3.0.4",
"nodemon": "^1.18.9",
"prettier": "^1.19.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
*/

import { Server } from '../src/server';
import { Mongo, FlatFile } from '../src/server/db';
import { FlatFile } from '../src/server/db';

export { Server, Mongo, FlatFile };
export { Server, FlatFile };
13 changes: 5 additions & 8 deletions src/server/db/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { DBFromEnv } from '.';
import { DBFromEnv, FlatFile } from '.';

test('MONGO_URI', () => {
process.env.MONGO_URI = 'test';
process.env.MONGO_DATABASE = 'database';
test('FLATFILE_DIR', () => {
process.env.FLATFILE_DIR = 'test';
const db = DBFromEnv();
expect(db.url).toBe('test');
expect(db.dbname).toBe('database');
delete process.env.MONGO_URI;
delete process.env.MONGO_DATABASE;
expect(db).toBeInstanceOf(FlatFile);
delete process.env.FLATFILE_DIR;
});
10 changes: 4 additions & 6 deletions src/server/db/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { InMemory } from './inmemory';
import { Mongo } from './mongo';
import { FlatFile } from './flatfile';

const DBFromEnv = () => {
if (process.env.MONGO_URI && process.env.MONGO_DATABASE) {
return new Mongo({
url: process.env.MONGO_URI,
dbname: process.env.MONGO_DATABASE,
if (process.env.FLATFILE_DIR) {
return new FlatFile({
dir: process.env.FLATFILE_DIR,
});
} else {
return new InMemory();
}
};

export { InMemory, Mongo, FlatFile, DBFromEnv };
export { InMemory, FlatFile, DBFromEnv };
162 changes: 0 additions & 162 deletions src/server/db/mongo.js

This file was deleted.

0 comments on commit 7b70cab

Please sign in to comment.