@laboratory-one/api-components 0.0.9 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@laboratory-one/api-components",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "description": "API components for Laboratory One",
5
5
  "author": "Laboratory One",
6
6
  "private": false,
@@ -18,16 +18,17 @@
18
18
  ],
19
19
  "scripts": {
20
20
  "lint": "eslint 'src/**/*.{js,ts,tsx}'",
21
- "lint:fix": "npm run format && npm run lint --fix",
21
+ "lint:fix": "yarn format && yarn lint --fix",
22
22
  "format": "prettier --write 'src/**/*.{js,ts,tsx}'",
23
23
  "build": "yarn build:esm && yarn build:cjs",
24
24
  "build:esm": "tsc",
25
25
  "build:cjs": "tsc --module commonjs --outDir dist/cjs",
26
26
  "generate": "prisma generate",
27
- "publish": "npm publish --access public",
28
27
  "publish:local": "yalc publish",
29
28
  "push:local": "yalc push",
30
- "push": "yarn build && yarn push:local"
29
+ "push": "yarn build && yarn push:local",
30
+ "version:patch": "./scripts/version.sh patch",
31
+ "version:minor": "./scripts/version.sh minor"
31
32
  },
32
33
  "dependencies": {
33
34
  "@nestjs/axios": "3.0.2",
@@ -3,6 +3,7 @@ import * as stytch from 'stytch';
3
3
  import { ConfigService } from '@nestjs/config';
4
4
 
5
5
  import { RegisterRequestDto } from '../user/dtos/register.request.dto';
6
+ import { handleError } from '../utils';
6
7
 
7
8
  @Injectable()
8
9
  export class AuthService {
@@ -31,8 +32,17 @@ export class AuthService {
31
32
  async login(data: RegisterRequestDto): Promise<boolean> {
32
33
  this.logger.debug('login');
33
34
 
34
- const res = await this.authClient.passwords.authenticate(data);
35
-
36
- return res['status_code'] === 200;
35
+ try {
36
+ const res = await this.authClient.passwords.authenticate(data);
37
+ return res['status_code'] === 200;
38
+ } catch (error: any) {
39
+ if (error.error_type === 'email_not_found') {
40
+ handleError('Email or password is wrong');
41
+ }
42
+
43
+ if (error.error_type === 'unauthorized_credentials') {
44
+ handleError('Email or password is wrong');
45
+ }
46
+ }
37
47
  }
38
48
  }