Skip to content

Commit

Permalink
Patch to 0.3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
bastienbeurier committed Nov 30, 2022
1 parent a6b7a09 commit b4785e4
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 20 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pizzly",
"version": "0.3.5",
"version": "0.3.6",
"description": "Pizzly's CLI tool.",
"type": "module",
"main": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nangohq/pizzly-frontend",
"version": "0.3.4",
"version": "0.3.6",
"description": "Pizzly's frontend library for OAuth handling.",
"type": "module",
"main": "dist/index.js",
Expand Down
8 changes: 1 addition & 7 deletions packages/server/lib/controllers/connection.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,9 @@ import connectionService from '../services/connection.service.js';
import type { NextFunction } from 'express';
import configService from '../services/config.service.js';
import { ProviderConfig, ProviderTemplate, Connection, ProviderAuthModes } from '../models.js';
import yaml from 'js-yaml';
import fs from 'fs';

class ConnectionController {
templates: { [key: string]: ProviderTemplate };

constructor() {
this.templates = yaml.load(fs.readFileSync('./templates.yaml').toString()) as { string: ProviderTemplate };
}
templates: { [key: string]: ProviderTemplate } = configService.getTemplates();

async getConnectionCredentials(req: Request, res: Response, next: NextFunction) {
try {
Expand Down
8 changes: 1 addition & 7 deletions packages/server/lib/controllers/oauth.contoller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import {
} from '../models.js';
import logger from '../utils/logger.js';
import type { NextFunction } from 'express';
import yaml from 'js-yaml';
import fs from 'fs';

class OAuthController {
sessionStore: OAuthSessionStore = {};
Expand All @@ -37,11 +35,7 @@ class OAuthController {
callback_err: (err: string) => `Did not get oauth_token and/or oauth_verifier in the callback: ${err}.`
};
callbackUrl = getOauthCallbackUrl();
templates: { [key: string]: ProviderTemplate };

constructor() {
this.templates = yaml.load(fs.readFileSync('./templates.yaml').toString()) as { string: ProviderTemplate };
}
templates: { [key: string]: ProviderTemplate } = configService.getTemplates();

public async oauthRequest(req: Request, res: Response, next: NextFunction) {
try {
Expand Down
16 changes: 15 additions & 1 deletion packages/server/lib/services/config.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import type { ProviderConfig } from '../models.js';
import type { ProviderConfig, ProviderTemplate } from '../models.js';
import db from '../db/database.js';
import yaml from 'js-yaml';
import fs from 'fs';

class ConfigService {
templates: { [key: string]: ProviderTemplate };

constructor() {
this.templates = yaml.load(
fs.readFileSync(process.env['PIZZLY_SERVER_RUN_MODE'] ? './packages/server/templates.yaml' : './templates.yaml').toString()
) as { string: ProviderTemplate };
}

async getProviderConfig(providerConfigKey: string): Promise<ProviderConfig | null> {
let result = await db.knex.withSchema(db.schema()).select('*').from(`_pizzly_configs`).where({ unique_key: providerConfigKey });

Expand Down Expand Up @@ -32,6 +42,10 @@ class ConfigService {
oauth_scopes: config.oauth_scopes
});
}

getTemplates(): { [key: string]: ProviderTemplate } {
return this.templates;
}
}

export default new ConfigService();
2 changes: 1 addition & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nangohq/pizzly-server",
"version": "0.3.4",
"version": "0.3.6",
"description": "Pizzly's server.",
"type": "module",
"main": "dist/server.js",
Expand Down

0 comments on commit b4785e4

Please sign in to comment.