working server with migrations as defined
BOOM BABY!!!
This commit is contained in:
@ -29,7 +29,7 @@ var strategy = new OAuth2Strategy({
|
||||
},
|
||||
function(accessToken, refreshToken, params, _, cb) {
|
||||
console.log(params);
|
||||
userService.findOrCreate(params.profile).then((user) => {
|
||||
userService.findOrCreate(params.profile).then((user: any) => {
|
||||
user.refreshToken = refreshToken;
|
||||
user.accessToken = accessToken;
|
||||
return cb(null, user);
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Database } from './db/db';
|
||||
import { Mapper } from './db/Mapper';
|
||||
import { Altitude, Job } from './db/migrations/Altitude';
|
||||
import { Altitude, Job } from './db/Altitude';
|
||||
import jobs from './migrationJobs';
|
||||
|
||||
let db = new Database({
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Mapper } from '../Mapper';
|
||||
import { Mapper } from './Mapper';
|
||||
|
||||
class Altitude {
|
||||
private migrations: Job[];
|
@ -1,4 +1,4 @@
|
||||
import { Database } from '../db/db';
|
||||
import { Database } from './db';
|
||||
|
||||
class Mapper {
|
||||
constructor(public database: Database) {}
|
||||
|
@ -1,2 +1,2 @@
|
||||
import { config } from 'dotenv';
|
||||
config({ silent: true })
|
||||
config();
|
||||
|
@ -1,11 +1,29 @@
|
||||
import { Job } from '../db/migrations/Altitude';
|
||||
import { Job } from '../db/Altitude';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
let jobs: Job[] = [];
|
||||
jobs.push({
|
||||
creator: 'Mason Payne',
|
||||
name: 'initializeDB',
|
||||
query: `CREATE TABLE Users (sub VARCHAR(36) NOT NULL UNIQUE, email VARCHAR(255) NOT NULL UNIQUE, accessToken VARCHAR(255), refreshToken VARCHAR(255), CreationTime TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (sub));`
|
||||
});
|
||||
|
||||
let files = fs.readdirSync(path.join(__dirname)).filter(file => file !== 'index.js');
|
||||
for (let i in files) {
|
||||
try {
|
||||
var data = fs.readFileSync(path.join(__dirname, files[i]), 'utf8');
|
||||
let parts = data.split('--down').filter(part => part.indexOf('--up') !== -1);
|
||||
if (parts.length) {
|
||||
// there is an up command in this file
|
||||
let upParts = parts[0].split('--up');
|
||||
jobs.push({
|
||||
creator: 'system',
|
||||
name: files[i],
|
||||
query: upParts[1].split('\n').join('')
|
||||
});
|
||||
}
|
||||
} catch(e) {
|
||||
console.log('Error:', e.stack);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(jobs);
|
||||
|
||||
// SYSTEM-BUILDER-jobs.push
|
||||
|
||||
|
Reference in New Issue
Block a user