Skip to content

Commit

Permalink
Merge pull request #18 from Selecro/main
Browse files Browse the repository at this point in the history
sync dev and main
  • Loading branch information
Szotkowski authored Jul 27, 2023
2 parents f833ddb + f94268a commit ee60fe5
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 66 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/codesee-arch-diagram.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This workflow was added by CodeSee. Learn more at https://codesee.io/
# This is v2.0 of this workflow file
on:
push:
branches:
- main
- dev
pull_request_target:
types: [opened, synchronize, reopened]

name: CodeSee

permissions: read-all

jobs:
codesee:
runs-on: ubuntu-latest
continue-on-error: true
name: Analyze the repo with CodeSee
steps:
- uses: Codesee-io/codesee-action@v2
with:
codesee-token: ${{ secrets.CODESEE_ARCH_DIAG_API_TOKEN }}
codesee-url: https://app.codesee.io
103 changes: 59 additions & 44 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@
"dependencies": {
"@loopback/authentication-jwt": "^0.14.1",
"@loopback/boot": "^6.0.0",
"@loopback/core": "^5.0.0",
"@loopback/core": "^5.1.0",
"@loopback/repository": "^6.0.0",
"@loopback/rest": "^13.0.0",
"@loopback/rest": "^13.1.0",
"@loopback/rest-explorer": "^6.0.0",
"@loopback/service-proxy": "^6.0.0",
"@loopback/service-proxy": "^6.1.0",
"dotenv": "^16.3.1",
"isemail": "^3.2.0",
"jsonwebtoken": "^9.0.0",
Expand Down
42 changes: 28 additions & 14 deletions src/controllers/socket.controller.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import {repository} from '@loopback/repository';
import * as dotenv from 'dotenv';
import {HttpErrors} from '@loopback/rest';
import * as fs from 'fs';
import * as https from 'https';
import path from 'path';
import {Server as SocketIOServer} from 'socket.io';
import {config} from '../datasources';
import {InstructionRepository} from '../repositories';
dotenv.config();
const Client = require('ssh2-sftp-client');
const sftp = new Client();
const fs = require('fs');

export class SocketController {
private server: https.Server;
Expand All @@ -17,17 +16,26 @@ export class SocketController {
constructor(
@repository(InstructionRepository)
private instructionRepository: InstructionRepository,
) { }
) {}

async start(): Promise<void> {
const options = {
key: fs.readFileSync(path.join(String(process.env.CERT_PATH), String(process.env.PRIVATE_KEY_FILE)), 'utf-8'),
cert: fs.readFileSync(path.join(String(process.env.CERT_PATH), String(process.env.CERT_FILE)), 'utf-8'),
key: fs.readFileSync(
path.join(
String(process.env.CERT_PATH),
String(process.env.PRIVATE_KEY_FILE),
),
'utf-8',
),
cert: fs.readFileSync(
path.join(String(process.env.CERT_PATH), String(process.env.CERT_FILE)),
'utf-8',
),
};
this.server = https.createServer(options);
this.io = new SocketIOServer(this.server, {
cors: {
origin: "*",
origin: '*',
methods: ['GET', 'POST'],
},
});
Expand All @@ -43,16 +51,22 @@ export class SocketController {
},
],
});
for (let item of data) {
for (const item of data) {
try {
sftp.get('/instructions/' + item.link, './public/' + item.link + '.jpg');
for (let item2 of item.steps) {
if (item2.link !== "string") {
sftp.get('/instructions/' + item2.link, './public/' + item2.link + '.jpg');
sftp.get(
'/instructions/' + item.link,
'./public/' + item.link + '.jpg',
);
for (const item2 of item.steps) {
if (item2.link !== 'string') {
sftp.get(
'/instructions/' + item2.link,
'./public/' + item2.link + '.jpg',
);
}
}
}
catch (_e) {
} catch (_e) {
throw new HttpErrors.UnprocessableEntity('Some error');
}
socket.emit('message', item);
await new Promise(resolve => setTimeout(resolve, 1000));
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class UserController {
@inject('services.email')
public emailService: EmailService,
@repository(UserRepository) public userRepository: UserRepository,
) { }
) {}

@post('/login', {
responses: {
Expand Down
13 changes: 11 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,17 @@ if (require.main === module) {
setServersFromRequest: true,
},
protocol: 'https',
key: fs.readFileSync(path.join(String(process.env.CERT_PATH), String(process.env.PRIVATE_KEY_FILE)), 'utf-8'),
cert: fs.readFileSync(path.join(String(process.env.CERT_PATH), String(process.env.CERT_FILE)), 'utf-8'),
key: fs.readFileSync(
path.join(
String(process.env.CERT_PATH),
String(process.env.PRIVATE_KEY_FILE),
),
'utf-8',
),
cert: fs.readFileSync(
path.join(String(process.env.CERT_PATH), String(process.env.CERT_FILE)),
'utf-8',
),
},
};
main(config).catch(err => {
Expand Down
4 changes: 2 additions & 2 deletions src/services/email.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {bind, BindingScope} from '@loopback/core';
import * as dotenv from 'dotenv';
import * as fs from 'fs';
import jwt from 'jsonwebtoken';
import {EmailDataSource} from '../datasources';
import {User} from '../models';
const fs = require('fs');
dotenv.config();

@bind({scope: BindingScope.TRANSIENT})
export class EmailService {
constructor() {}
constructor() { }

public generateVerificationToken(userId: number): string {
const secret = process.env.JWT_SECRET ?? '';
Expand Down

0 comments on commit ee60fe5

Please sign in to comment.