Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server
1 result
Show changes
Commits on Source (15)
Showing
with 11779 additions and 16994 deletions
...@@ -15,6 +15,6 @@ module.exports = { ...@@ -15,6 +15,6 @@ module.exports = {
'@typescript-eslint/interface-name-prefix': 'off', '@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off', '@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-explicit-any': 'warn',
}, },
}; };
{ {
"workbench.colorCustomizations": { "workbench.colorCustomizations": {
"activityBar.activeBackground": "#b299e5", "activityBar.activeBackground": "#b299e5",
"activityBar.activeBorder": "#f9ece6", "activityBar.activeBorder": "#f9ece6",
"activityBar.background": "#b299e5", "activityBar.background": "#b299e5",
"activityBar.foreground": "#15202b", "activityBar.foreground": "#15202b",
"activityBar.inactiveForeground": "#15202b99", "activityBar.inactiveForeground": "#15202b99",
"activityBarBadge.background": "#f9ece6", "activityBarBadge.background": "#f9ece6",
"activityBarBadge.foreground": "#15202b", "activityBarBadge.foreground": "#15202b",
"statusBar.background": "#9370db", "statusBar.background": "#9370db",
"statusBar.foreground": "#15202b", "statusBar.foreground": "#15202b",
"statusBarItem.hoverBackground": "#7447d1", "statusBarItem.hoverBackground": "#7447d1",
"titleBar.activeBackground": "#9370db", "titleBar.activeBackground": "#9370db",
"titleBar.activeForeground": "#15202b", "titleBar.activeForeground": "#15202b",
"titleBar.inactiveBackground": "#9370db99", "titleBar.inactiveBackground": "#9370db99",
"titleBar.inactiveForeground": "#15202b99" "titleBar.inactiveForeground": "#15202b99"
}, },
"peacock.color": "#9370DB", "peacock.color": "#9370DB",
"javascript.format.enable": false, "javascript.format.enable": false,
"editor.codeActionsOnSave": { "editor.codeActionsOnSave": {
"source.fixAll.eslint": true "source.fixAll.eslint": true
}, },
"eslint.validate": ["typescript"], "eslint.validate": ["typescript"],
"[html]": { "[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode" "editor.defaultFormatter": "esbenp.prettier-vscode"
}, },
"[javascript]": { "[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode" "editor.defaultFormatter": "esbenp.prettier-vscode"
}, },
"[json]": { "[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode" "editor.defaultFormatter": "esbenp.prettier-vscode"
}, },
"[scss]": { "[scss]": {
"editor.defaultFormatter": "esbenp.prettier-vscode" "editor.defaultFormatter": "esbenp.prettier-vscode"
}, },
"[typescript]": { "[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode" "editor.defaultFormatter": "esbenp.prettier-vscode"
}, },
"editor.formatOnSave": true, "editor.formatOnSave": true,
"typescript.preferences.importModuleSpecifier": "relative" "typescript.preferences.importModuleSpecifier": "relative",
} "cSpell.words": ["aptic", "cnfs", "grandlyon", "nestjs", "photonban"]
\ No newline at end of file }
...@@ -2,6 +2,17 @@ ...@@ -2,6 +2,17 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
### [2.1.3](https://forge.grandlyon.com/web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/compare/v2.1.2...v2.1.3) (2023-03-02)
### Bug Fixes
* **cnfsId:** setCNFSid now uses the same id that rdvs ([e4bf72c](https://forge.grandlyon.com/web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/e4bf72c56b1aeefb59004bd5604a4a3eaf3c507f))
* **structure-dto:** free workshop are no longer required ([0888b57](https://forge.grandlyon.com/web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/0888b57417a2f1a254274db6f6b33d081678faea))
* **structureService:** filter keys are cast to booleans no matter the case ([3b2fdce](https://forge.grandlyon.com/web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/3b2fdce975e02674fb72c0f7384751b3a4cdf7f9))
* **structureService:** setCNFSid now checks if the cnfsID has meeting opened on rdvs ([a3e316a](https://forge.grandlyon.com/web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/a3e316ae130575a961287fcf31026c0df4cd01ae))
* **structureService:** Update calls to setCNFSid ([65d6ad0](https://forge.grandlyon.com/web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/65d6ad0ecbdaf16ed0a4dc683caa073667427a71))
### [2.1.2](https://forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/compare/v2.1.1...v2.1.2) (2023-02-23) ### [2.1.2](https://forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/compare/v2.1.1...v2.1.2) (2023-02-23)
......
This diff is collapsed.
{ {
"name": "ram_server", "name": "ram_server",
"private": true, "private": true,
"version": "2.1.2", "version": "2.1.3",
"description": "Nest TypeScript starter repository", "description": "Nest TypeScript starter repository",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
......
...@@ -62,7 +62,7 @@ export class AdminController { ...@@ -62,7 +62,7 @@ export class AdminController {
@Roles('admin') @Roles('admin')
@Get('adminStructuresList') @Get('adminStructuresList')
@ApiOperation({ description: 'Get pending structures for validation' }) @ApiOperation({ description: 'Get pending structures for validation' })
public async getAdminStructuresList(): Promise<any> { public async getAdminStructuresList() {
this.logger.debug('getAdminStructuresList'); this.logger.debug('getAdminStructuresList');
const structuresList = { claimed: [], inClaim: [], toClaim: [], incomplete: [] }; const structuresList = { claimed: [], inClaim: [], toClaim: [], incomplete: [] };
const inClaimStructures = await this.getPendingAttachments(); const inClaimStructures = await this.getPendingAttachments();
......
import { Controller, Post, Body } from '@nestjs/common'; import { Body, Controller, Post } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import { AuthService } from './auth.service'; import { AuthService } from './auth.service';
import { LoginDto } from './login-dto'; import { LoginDto } from './login-dto';
...@@ -9,7 +9,7 @@ export class AuthController { ...@@ -9,7 +9,7 @@ export class AuthController {
constructor(private authService: AuthService) {} constructor(private authService: AuthService) {}
@Post('login') @Post('login')
async login(@Body() loginDto: LoginDto): Promise<{ username; name; surname; token }> { async login(@Body() loginDto: LoginDto) {
return this.authService.login(loginDto); return this.authService.login(loginDto);
} }
} }
...@@ -57,6 +57,10 @@ describe('AuthService', () => { ...@@ -57,6 +57,10 @@ describe('AuthService', () => {
}); });
describe('login', () => { describe('login', () => {
let _createToken;
beforeAll(() => {
_createToken = jest.spyOn(AuthService.prototype as any, '_createToken');
});
it('should login user pauline.dupont@mii.com', async () => { it('should login user pauline.dupont@mii.com', async () => {
// Token creation mock // Token creation mock
const token = { const token = {
...@@ -64,7 +68,6 @@ describe('AuthService', () => { ...@@ -64,7 +68,6 @@ describe('AuthService', () => {
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InBhdWxpbmUuZHVwb250QG1paS5jb20iLCJyb2xlIjowLCJpYXQiOjE2MjAwNDg5MDYsImV4cCI6MTYyMDEzNTMwNn0.jbLazQNJzU_X9Yp1S7XH1rYD5W7yyd1pdGebmkyTMB4', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InBhdWxpbmUuZHVwb250QG1paS5jb20iLCJyb2xlIjowLCJpYXQiOjE2MjAwNDg5MDYsImV4cCI6MTYyMDEzNTMwNn0.jbLazQNJzU_X9Yp1S7XH1rYD5W7yyd1pdGebmkyTMB4',
expiresAt: '2021-05-04T15:35:06.663+02:00', expiresAt: '2021-05-04T15:35:06.663+02:00',
}; };
const _createToken = jest.spyOn(AuthService.prototype as any, '_createToken');
_createToken.mockImplementation(() => token); _createToken.mockImplementation(() => token);
const loginDto: LoginDto = { email: 'pauline.dupont@mii.com', password: 'test1A!!' }; //NOSONAR const loginDto: LoginDto = { email: 'pauline.dupont@mii.com', password: 'test1A!!' }; //NOSONAR
...@@ -85,7 +88,6 @@ describe('AuthService', () => { ...@@ -85,7 +88,6 @@ describe('AuthService', () => {
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InBhdWxpbmUuZHVwb250QG1paS5jb20iLCJyb2xlIjowLCJpYXQiOjE2MjAwNDg5MDYsImV4cCI6MTYyMDEzNTMwNn0.jbLazQNJzU_X9Yp1S7XH1rYD5W7yyd1pdGebmkyTMB4', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InBhdWxpbmUuZHVwb250QG1paS5jb20iLCJyb2xlIjowLCJpYXQiOjE2MjAwNDg5MDYsImV4cCI6MTYyMDEzNTMwNn0.jbLazQNJzU_X9Yp1S7XH1rYD5W7yyd1pdGebmkyTMB4',
expiresAt: '2021-05-04T15:35:06.663+02:00', expiresAt: '2021-05-04T15:35:06.663+02:00',
}; };
const _createToken = jest.spyOn(AuthService.prototype as any, '_createToken');
_createToken.mockImplementation(() => token); _createToken.mockImplementation(() => token);
const loginDto: LoginDto = { email: 'jacques.dupont@mii.com', password: 'test1A!!' }; //NOSONAR const loginDto: LoginDto = { email: 'jacques.dupont@mii.com', password: 'test1A!!' }; //NOSONAR
...@@ -105,7 +107,6 @@ describe('AuthService', () => { ...@@ -105,7 +107,6 @@ describe('AuthService', () => {
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InBhdWxpbmUuZHVwb250QG1paS5jb20iLCJyb2xlIjowLCJpYXQiOjE2MjAwNDg5MDYsImV4cCI6MTYyMDEzNTMwNn0.jbLazQNJzU_X9Yp1S7XH1rYD5W7yyd1pdGebmkyTMB4', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InBhdWxpbmUuZHVwb250QG1paS5jb20iLCJyb2xlIjowLCJpYXQiOjE2MjAwNDg5MDYsImV4cCI6MTYyMDEzNTMwNn0.jbLazQNJzU_X9Yp1S7XH1rYD5W7yyd1pdGebmkyTMB4',
expiresAt: '2021-05-04T15:35:06.663+02:00', expiresAt: '2021-05-04T15:35:06.663+02:00',
}; };
const _createToken = jest.spyOn(AuthService.prototype as any, '_createToken');
_createToken.mockImplementation(() => token); _createToken.mockImplementation(() => token);
const loginDto: LoginDto = { email: 'toto@mii.com', password: 'test1A!!' }; //NOSONAR const loginDto: LoginDto = { email: 'toto@mii.com', password: 'test1A!!' }; //NOSONAR
...@@ -125,7 +126,6 @@ describe('AuthService', () => { ...@@ -125,7 +126,6 @@ describe('AuthService', () => {
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InBhdWxpbmUuZHVwb250QG1paS5jb20iLCJyb2xlIjowLCJpYXQiOjE2MjAwNDg5MDYsImV4cCI6MTYyMDEzNTMwNn0.jbLazQNJzU_X9Yp1S7XH1rYD5W7yyd1pdGebmkyTMB4', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InBhdWxpbmUuZHVwb250QG1paS5jb20iLCJyb2xlIjowLCJpYXQiOjE2MjAwNDg5MDYsImV4cCI6MTYyMDEzNTMwNn0.jbLazQNJzU_X9Yp1S7XH1rYD5W7yyd1pdGebmkyTMB4',
expiresAt: '2021-05-04T15:35:06.663+02:00', expiresAt: '2021-05-04T15:35:06.663+02:00',
}; };
const _createToken = jest.spyOn(AuthService.prototype as any, '_createToken');
_createToken.mockImplementation(() => token); _createToken.mockImplementation(() => token);
const loginDto: LoginDto = { email: 'jacques.dupont@mii.com', password: '1' }; //NOSONAR const loginDto: LoginDto = { email: 'jacques.dupont@mii.com', password: '1' }; //NOSONAR
......
import { HttpException, HttpStatus, Injectable } from '@nestjs/common'; import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { UsersService } from '../users/services/users.service';
import { JwtService } from '@nestjs/jwt'; import { JwtService } from '@nestjs/jwt';
import { LoginDto } from './login-dto';
import { DateTime } from 'luxon'; import { DateTime } from 'luxon';
import { IUser } from '../users/interfaces/user.interface';
import { User } from '../users/schemas/user.schema'; import { User } from '../users/schemas/user.schema';
import { UsersService } from '../users/services/users.service';
import { LoginDto } from './login-dto';
@Injectable() @Injectable()
export class AuthService { export class AuthService {
constructor(private usersService: UsersService, private jwtService: JwtService) {} constructor(private usersService: UsersService, private jwtService: JwtService) {}
async validateUser(loginDto: LoginDto): Promise<any> { async validateUser(loginDto: LoginDto): Promise<IUser> {
const user = await this.usersService.findOne(loginDto.email); const user = await this.usersService.findOne(loginDto.email);
if (user) { if (user) {
return user; return user;
...@@ -17,7 +18,7 @@ export class AuthService { ...@@ -17,7 +18,7 @@ export class AuthService {
return null; return null;
} }
async login(loginDto: LoginDto): Promise<{ username; name; surname; token }> { async login(loginDto: LoginDto) {
// find user in db // find user in db
const user: User = await this.usersService.findByLogin(loginDto); const user: User = await this.usersService.findByLogin(loginDto);
if (!user.emailVerified) { if (!user.emailVerified) {
...@@ -35,7 +36,7 @@ export class AuthService { ...@@ -35,7 +36,7 @@ export class AuthService {
}; };
} }
private _createToken(user: User): any { private _createToken(user: User) {
const local = DateTime.local().setZone('Europe/Paris'); const local = DateTime.local().setZone('Europe/Paris');
return { return {
accessToken: this.jwtService.sign({ email: user.email, role: user.role }), accessToken: this.jwtService.sign({ email: user.email, role: user.role }),
......
import { ExtractJwt, Strategy } from 'passport-jwt';
import { PassportStrategy } from '@nestjs/passport';
import { HttpException, HttpStatus, Injectable } from '@nestjs/common'; import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { PassportStrategy } from '@nestjs/passport';
import { ExtractJwt, Strategy } from 'passport-jwt';
import { AuthService } from '../auth.service'; import { AuthService } from '../auth.service';
@Injectable() @Injectable()
...@@ -13,7 +13,7 @@ export class JwtStrategy extends PassportStrategy(Strategy) { ...@@ -13,7 +13,7 @@ export class JwtStrategy extends PassportStrategy(Strategy) {
}); });
} }
async validate(payload: any) { async validate(payload) {
const user = await this.authService.validateUser(payload); const user = await this.authService.validateUser(payload);
if (!user) { if (!user) {
throw new HttpException('Invalid token', HttpStatus.UNAUTHORIZED); throw new HttpException('Invalid token', HttpStatus.UNAUTHORIZED);
......
import { Body, Controller, Post } from '@nestjs/common'; import { Body, Controller, Post } from '@nestjs/common';
import { ContactMessage } from './schemas/contact-message.schema';
import { ContactService } from './contact.service';
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import { ContactService } from './contact.service';
import { ContactMessage } from './schemas/contact-message.schema';
@ApiTags('contact') @ApiTags('contact')
@Controller('contact') @Controller('contact')
...@@ -9,7 +9,7 @@ export class ContactController { ...@@ -9,7 +9,7 @@ export class ContactController {
constructor(private contactService: ContactService) {} constructor(private contactService: ContactService) {}
@Post('message') @Post('message')
public async sendContactMessage(@Body() data: { contactMessage: ContactMessage }): Promise<any> { public async sendContactMessage(@Body() data: { contactMessage: ContactMessage }): Promise<unknown> {
return this.contactService.sendMessage(data.contactMessage); return this.contactService.sendMessage(data.contactMessage);
} }
} }
import { HttpModule } from '@nestjs/axios';
import { HttpStatus } from '@nestjs/common'; import { HttpStatus } from '@nestjs/common';
import { ContactMessage } from './schemas/contact-message.schema';
import { Test, TestingModule } from '@nestjs/testing'; import { Test, TestingModule } from '@nestjs/testing';
import { MailerModule } from '../mailer/mailer.module';
import { ContactService } from './contact.service';
import { MailerService } from '../mailer/mailer.service';
import { MailerMockService } from '../../test/mock/services/mailer.mock.service'; import { MailerMockService } from '../../test/mock/services/mailer.mock.service';
import { HttpModule } from '@nestjs/axios';
import { ConfigurationService } from '../configuration/configuration.service'; import { ConfigurationService } from '../configuration/configuration.service';
import { MailerModule } from '../mailer/mailer.module';
import { MailerService } from '../mailer/mailer.service';
import { ContactService } from './contact.service';
import { ContactMessage } from './schemas/contact-message.schema';
describe('ContactService', () => { describe('ContactService', () => {
let service: ContactService; let service: ContactService;
...@@ -25,7 +25,7 @@ describe('ContactService', () => { ...@@ -25,7 +25,7 @@ describe('ContactService', () => {
}); });
it('should send message with status OK', async () => { it('should send message with status OK', async () => {
const res = await service.sendMessage(new ContactMessage()); const res = (await service.sendMessage(new ContactMessage())) as { data: { status: unknown } };
expect(res.data.status).toBe(HttpStatus.OK); expect(res.data.status).toBe(HttpStatus.OK);
}); });
}); });
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { MailerService } from '../mailer/mailer.service';
import { ContactMessage } from './schemas/contact-message.schema';
import * as ejs from 'ejs'; import * as ejs from 'ejs';
import * as sanitizeHtml from 'sanitize-html'; import * as sanitizeHtml from 'sanitize-html';
import { MailerService } from '../mailer/mailer.service';
import { ContactMessage } from './schemas/contact-message.schema';
@Injectable() @Injectable()
export class ContactService { export class ContactService {
constructor(private readonly mailerService: MailerService) {} constructor(private readonly mailerService: MailerService) {}
public async sendMessage(contactMessage: ContactMessage): Promise<any> { public async sendMessage(contactMessage: ContactMessage): Promise<unknown> {
const config = this.mailerService.config; const config = this.mailerService.config;
const ejsPath = this.mailerService.getTemplateLocation(config.templates.contactMessage.ejs); const ejsPath = this.mailerService.getTemplateLocation(config.templates.contactMessage.ejs);
const jsonConfig = this.mailerService.loadJsonConfig(config.templates.contactMessage.json); const jsonConfig = this.mailerService.loadJsonConfig(config.templates.contactMessage.json);
......
import { HttpService } from '@nestjs/axios'; import { HttpService } from '@nestjs/axios';
import { Injectable, Logger } from '@nestjs/common'; import { Injectable, Logger } from '@nestjs/common';
import { AxiosResponse } from 'axios'; import { AxiosResponse } from 'axios';
import * as FormData from 'form-data';
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
import * as FormData from 'form-data';
import { ConfigurationService } from '../configuration/configuration.service'; import { ConfigurationService } from '../configuration/configuration.service';
@Injectable() @Injectable()
export class MailerService { export class MailerService {
...@@ -12,23 +12,11 @@ export class MailerService { ...@@ -12,23 +12,11 @@ export class MailerService {
this.config = this.configurationService.config; this.config = this.configurationService.config;
} }
/** public async send(to: string | { email: string }[], subject: string, html: string): Promise<AxiosResponse<unknown>> {
* Send an email
*
* @param {string} from
* @param {string} to
* @param {string} replyTo
* @param {string} subject
* @param {string} html
* @param {string} text
*/
public async send(to: string | { email: string }[], subject: string, html: string): Promise<AxiosResponse<any>> {
const emailsToSend = typeof to === 'string' ? [{ email: to }] : to; const emailsToSend = typeof to === 'string' ? [{ email: to }] : to;
const formData = new FormData(); const formData = new FormData();
const data = JSON.stringify({ const data = JSON.stringify({
// eslint-disable-next-line camelcase
from_email: this.config.from, from_email: this.config.from,
// eslint-disable-next-line camelcase
from_name: this.config.from_name, from_name: this.config.from_name,
to: emailsToSend, to: emailsToSend,
reply_to: 'inclusionnumerique@grandlyon.com', reply_to: 'inclusionnumerique@grandlyon.com',
...@@ -62,10 +50,8 @@ export class MailerService { ...@@ -62,10 +50,8 @@ export class MailerService {
/** /**
* Get email template location from config directory and given filename. Also, check if file exists. * Get email template location from config directory and given filename. Also, check if file exists.
*
* @param {string} filename
*/ */
public getTemplateLocation(filename) { public getTemplateLocation(filename: string) {
const ejsPath = path.join(this.config.templates.directory, filename); const ejsPath = path.join(this.config.templates.directory, filename);
if (!fs.existsSync(ejsPath)) { if (!fs.existsSync(ejsPath)) {
throw new Error(`Email template '${filename}' cannot be found in ${this.config.templates.directory}`); throw new Error(`Email template '${filename}' cannot be found in ${this.config.templates.directory}`);
...@@ -75,10 +61,8 @@ export class MailerService { ...@@ -75,10 +61,8 @@ export class MailerService {
/** /**
* Load email json config file from config directory and given filename. Also, check if file exists * Load email json config file from config directory and given filename. Also, check if file exists
*
* @param {filename} filename
*/ */
public loadJsonConfig(filename) { public loadJsonConfig(filename: string) {
const jsonPath = path.join(this.config.templates.directory, filename); const jsonPath = path.join(this.config.templates.directory, filename);
if (!fs.existsSync(jsonPath)) { if (!fs.existsSync(jsonPath)) {
throw new Error(`Email json definition file '${filename}' cannot be found in ${this.config.templates.directory}`); throw new Error(`Email json definition file '${filename}' cannot be found in ${this.config.templates.directory}`);
......
import { StructuresServiceMock } from './../../test/mock/services/structures.mock.service';
import { StructuresService } from './../structures/services/structures.service';
import { getModelToken } from '@nestjs/mongoose'; import { getModelToken } from '@nestjs/mongoose';
import { Test, TestingModule } from '@nestjs/testing'; import { Test, TestingModule } from '@nestjs/testing';
import { import {
createPersonalOffersDtoDataMock, createPersonalOffersDtoDataMock,
updatePersonalOffersDtoDataMock,
personalOffersDataMock, personalOffersDataMock,
updatePersonalOffersDtoDataMock,
} from '../../test/mock/data/personalOffers.mock.data'; } from '../../test/mock/data/personalOffers.mock.data';
import { PersonalOffersService } from './personal-offers.service';
import { UsersService } from '../users/services/users.service';
import { UsersServiceMock } from '../../test/mock/services/user.mock.service'; import { UsersServiceMock } from '../../test/mock/services/user.mock.service';
import { UsersService } from '../users/services/users.service';
import { StructuresServiceMock } from './../../test/mock/services/structures.mock.service';
import { StructuresService } from './../structures/services/structures.service';
import { PersonalOffersService } from './personal-offers.service';
describe('PersonalOffersService', () => { describe('PersonalOffersService', () => {
let service: PersonalOffersService; let service: PersonalOffersService;
...@@ -61,7 +61,7 @@ describe('PersonalOffersService', () => { ...@@ -61,7 +61,7 @@ describe('PersonalOffersService', () => {
it('should return exception if personal offer is not found for given id', async () => { it('should return exception if personal offer is not found for given id', async () => {
personalOfferModelMock.findById.mockReturnThis(); personalOfferModelMock.findById.mockReturnThis();
personalOfferModelMock.exec.mockResolvedValueOnce(null); personalOfferModelMock.exec.mockResolvedValueOnce(null);
let error: any; let error;
try { try {
await service.findOne('abcd'); await service.findOne('abcd');
} catch (e) { } catch (e) {
...@@ -90,7 +90,7 @@ describe('PersonalOffersService', () => { ...@@ -90,7 +90,7 @@ describe('PersonalOffersService', () => {
it('should return exception if personal offer is not found for given id', async () => { it('should return exception if personal offer is not found for given id', async () => {
personalOfferModelMock.findById.mockReturnThis(); personalOfferModelMock.findById.mockReturnThis();
personalOfferModelMock.exec.mockResolvedValueOnce(null); personalOfferModelMock.exec.mockResolvedValueOnce(null);
let error: any; let error;
try { try {
await service.update('abcd', updatePersonalOffersDtoDataMock[1]); await service.update('abcd', updatePersonalOffersDtoDataMock[1]);
} catch (e) { } catch (e) {
...@@ -110,7 +110,7 @@ describe('PersonalOffersService', () => { ...@@ -110,7 +110,7 @@ describe('PersonalOffersService', () => {
it('should return exception if personal offer is not found for given id', async () => { it('should return exception if personal offer is not found for given id', async () => {
personalOfferModelMock.findById.mockReturnThis(); personalOfferModelMock.findById.mockReturnThis();
personalOfferModelMock.exec.mockResolvedValueOnce(null); personalOfferModelMock.exec.mockResolvedValueOnce(null);
let error: any; let error;
try { try {
await service.delete('abcd'); await service.delete('abcd');
} catch (e) { } catch (e) {
......
...@@ -2,17 +2,17 @@ import { Injectable } from '@nestjs/common'; ...@@ -2,17 +2,17 @@ import { Injectable } from '@nestjs/common';
import * as GhostAdminAPI from '@tryghost/admin-api'; import * as GhostAdminAPI from '@tryghost/admin-api';
import * as _ from 'lodash'; import * as _ from 'lodash';
import { ConfigurationService } from '../configuration/configuration.service'; import { ConfigurationService } from '../configuration/configuration.service';
import { rewriteGhostImgUrl } from '../shared/utils';
import { TagEnum } from './enums/tag.enum'; import { TagEnum } from './enums/tag.enum';
import { Post } from './schemas/post.schema'; import { Post } from './schemas/post.schema';
import { Tag } from './schemas/tag.schema'; import { Tag } from './schemas/tag.schema';
import { rewriteGhostImgUrl } from '../shared/utils';
@Injectable() @Injectable()
export class PostsService { export class PostsService {
// ID's use in ghost tag description in order to categories tags. // ID's use in ghost tag description in order to categories tags.
public readonly locationCategory = 'commune'; public readonly locationCategory = 'commune';
public readonly publicCategory = 'public'; public readonly publicCategory = 'public';
private api: any; private api;
constructor(private readonly configService: ConfigurationService) { constructor(private readonly configService: ConfigurationService) {
// Configure Ghost client // Configure Ghost client
...@@ -61,7 +61,7 @@ export class PostsService { ...@@ -61,7 +61,7 @@ export class PostsService {
return publicTags; return publicTags;
} }
public arraymove(arr, fromIndex, toIndex): Array<any> { public arraymove(arr, fromIndex, toIndex): Array<unknown> {
const element = arr[fromIndex]; const element = arr[fromIndex];
arr.splice(fromIndex, 1); arr.splice(fromIndex, 1);
arr.splice(toIndex, 0, element); arr.splice(toIndex, 0, element);
......
export class Pagination { export class Pagination {
limit: number; limit: number;
next: any;
page: number; page: number;
pages: number; pages: number;
prev: any;
total: number; total: number;
prev: unknown;
next: unknown;
} }
...@@ -48,9 +48,7 @@ export class StructureDto { ...@@ -48,9 +48,7 @@ export class StructureDto {
@IsNotEmpty() @IsNotEmpty()
categories: any; categories: any;
@ApiProperty({ required: true }) freeWorkShop: string;
@IsNotEmpty()
freeWorkShop: boolean | string;
@ApiProperty({ required: true }) @ApiProperty({ required: true })
@IsNotEmpty() @IsNotEmpty()
......
export interface CNFSStructure { export interface CNFSStructure {
id: string; id: string;
structureId: string;
nom: string; nom: string;
commune: string; commune: string;
code_postal: string; code_postal: string;
...@@ -12,6 +13,7 @@ export interface CNFSStructure { ...@@ -12,6 +13,7 @@ export interface CNFSStructure {
services: string; services: string;
conditions_access: string; conditions_access: string;
labels_nationaux: string; labels_nationaux: string;
prise_rdv?: string;
pivot?: string; pivot?: string;
horaires?: string; horaires?: string;
site_web?: string; site_web?: string;
......
...@@ -105,7 +105,6 @@ export class Structure { ...@@ -105,7 +105,6 @@ export class Structure {
categories: StructureCategories; categories: StructureCategories;
@Prop() @Prop()
@IsNotEmpty()
/** 'Oui' | 'Oui sous condition' | 'Non' */ /** 'Oui' | 'Oui sous condition' | 'Non' */
freeWorkShop: string; freeWorkShop: string;
......