Skip to content

Commit

Permalink
can create superuser
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusandra committed Sep 27, 2019
1 parent 7268d8a commit 2832de1
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 15 deletions.
5 changes: 5 additions & 0 deletions packages/insights-api/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ const app: Application = express(feathers());

// Load app configuration
app.configure(configuration());

if (process.env.INSIGHTS_DATA) {
app.set('nedb', process.env.INSIGHTS_DATA)
}

// Enable security, CORS, compression, favicon and body parsing
app.use(helmet());
app.use(cors());
Expand Down
1 change: 1 addition & 0 deletions packages/insights-api/src/services/users/users.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ interface UserData {
_id?: string;
email: string;
password: string;
roles: string[];
}

export class Users extends Service<UserData> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// - INSIGHTS_SUPERUSER_EMAIL
// - INSIGHTS_SUPERUSER_PASSWORD

const app = require('insights-api/src')
const prompt = require('prompt-promise')
const randomString = require('../lib/random-string')
import app from '../../insights-api/src/app'
import prompt from 'prompt-promise'
import randomString from '../lib/random-string'

const azAZ09 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'

Expand Down Expand Up @@ -40,7 +40,7 @@ async function main () {
}

try {
await app.service('api/users').create({
await app.service('users').create({
email: email,
password: password,
roles: ['superuser']
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-console */
const logger = require('winston')
const app = require('insights-core/src')
const app = require('insights-api/src')

const port = process.env.INSIGHTS_PORT || app.get('port')

Expand Down
2 changes: 1 addition & 1 deletion packages/insights-cli/bin/insights
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env node
#!/usr/bin/env ts-node

var path = require('path')
var program = require('commander')
Expand Down
2 changes: 1 addition & 1 deletion packages/insights-cli/bin/insights-createsecret
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env node
#!/usr/bin/env ts-node

var fs = require('fs')
var path = require('path')
Expand Down
5 changes: 2 additions & 3 deletions packages/insights-cli/bin/insights-createsuperuser
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env node
#!/usr/bin/env ts-node

var path = require('path')
var program = require('commander')
Expand All @@ -15,8 +15,7 @@ program.version(pkg.version)
.option('-d --develop', 'Run in development mode')
.parse(process.argv)

process.env.NODE_ENV = program.develop ? 'development' : 'production'
process.env.NODE_CONFIG_DIR = path.join(__dirname, '..', 'config')
process.env.NODE_CONFIG_DIR = path.join(__dirname, '..', '..', 'insights-api', 'config')
process.env.INSIGHTS_DATA = program.data || path.join(require('os').homedir(), '.insights', 'data')

if (program.email) {
Expand Down
2 changes: 1 addition & 1 deletion packages/insights-cli/bin/insights-start
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env node
#!/usr/bin/env ts-node

// Thanks to https://github.com/mysamai/mysam/blob/master/bin/mysam for this script!

Expand Down
7 changes: 6 additions & 1 deletion packages/insights-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
],
"peerDependencies": {},
"dependencies": {
"commander": "^2.10.0"
"commander": "^2.10.0",
"prompt-promise": "^1.0.3"
},
"devDependencies": {
"ts-node": "^8.4.1",
"typescript": "^3.6.3"
}
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"module": "commonjs",
"baseUrl": "./src",
"outDir": "./lib",
"strict": true,
"strict": false,
"esModuleInterop": true
},
"exclude": [
Expand Down
29 changes: 27 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9534,6 +9534,11 @@ keymaster@^1.6.2:
resolved "https://registry.yarnpkg.com/keymaster/-/keymaster-1.6.2.tgz#e1ae54d0ea9488f9f60b66b668f02e9a1946c6eb"
integrity sha1-4a5U0OqUiPn2C2a2aPAumhlGxus=

keypress@~0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/keypress/-/keypress-0.2.1.tgz#1e80454250018dbad4c3fe94497d6e67b6269c77"
integrity sha1-HoBFQlABjbrUw/6USX1uZ7YmnHc=

killable@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/killable/-/killable-1.0.1.tgz#4c8ce441187a061c7474fb87ca08e2a638194892"
Expand Down Expand Up @@ -10441,6 +10446,18 @@ nanomatch@^1.2.9:
snapdragon "^0.8.1"
to-regex "^3.0.1"

native-or-another@~2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/native-or-another/-/native-or-another-2.0.0.tgz#17a567f92beea9cd71acff96a7681a735eca3bff"
integrity sha1-F6Vn+Svuqc1xrP+Wp2gac17KO/8=
dependencies:
native-or-bluebird "^1.1.2"

native-or-bluebird@^1.1.2:
version "1.2.0"
resolved "https://registry.yarnpkg.com/native-or-bluebird/-/native-or-bluebird-1.2.0.tgz#39c47bfd7825d1fb9ffad32210ae25daadf101c9"
integrity sha1-OcR7/Xgl0fuf+tMiEK4l2q3xAck=

natural-compare@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
Expand Down Expand Up @@ -12611,6 +12628,14 @@ promise@^7.1.1:
dependencies:
asap "~2.0.3"

prompt-promise@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/prompt-promise/-/prompt-promise-1.0.3.tgz#78ce4fcb9a14a108c49174f2d808c440d1bde265"
integrity sha1-eM5Py5oUoQjEkXTy2AjEQNG94mU=
dependencies:
keypress "~0.2.1"
native-or-another "~2.0.0"

prompts@^2.0.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/prompts/-/prompts-2.2.1.tgz#f901dd2a2dfee080359c0e20059b24188d75ad35"
Expand Down Expand Up @@ -15289,7 +15314,7 @@ ts-node-dev@^1.0.0-pre.43:
ts-node "*"
tsconfig "^7.0.0"

ts-node@*:
ts-node@*, ts-node@^8.4.1:
version "8.4.1"
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.4.1.tgz#270b0dba16e8723c9fa4f9b4775d3810fd994b4f"
integrity sha512-5LpRN+mTiCs7lI5EtbXmF/HfMeCjzt7DH9CZwtkr6SywStrNQC723wG+aOWFiLNn7zT3kD/RnFqi3ZUfr4l5Qw==
Expand Down Expand Up @@ -15429,7 +15454,7 @@ typescript-tuple@^2.2.1:
dependencies:
typescript-compare "^0.0.2"

[email protected], typescript@^3.5.3:
[email protected], typescript@^3.5.3, typescript@^3.6.3:
version "3.6.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.6.3.tgz#fea942fabb20f7e1ca7164ff626f1a9f3f70b4da"
integrity sha512-N7bceJL1CtRQ2RiG0AQME13ksR7DiuQh/QehubYcghzv20tnh+MQnQIuJddTmsbqYj+dztchykemz0zFzlvdQw==
Expand Down

0 comments on commit 2832de1

Please sign in to comment.