Passed
Push — master ( e6aee2...1ab6c1 )
by Leandro
01:23
created

src/utils/jwt.ts   A

Complexity

Total Complexity 2
Complexity/F 1

Size

Lines of Code 13
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 9
mnd 0
bc 0
fnc 2
dl 0
loc 13
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A jwt.ts ➔ createJwt 0 4 1
A jwt.ts ➔ checkJwt 0 4 1
1
import jwt from "jsonwebtoken";
2
3
export function createJwt(payload: object): string {
4
  return jwt.sign(payload, process.env.JWT_SECRET, {
5
    expiresIn: process.env.JWT_EXPIRATION,
6
  });
7
}
8
9
export function checkJwt(authorization: string): any {
10
  const [,token] = authorization.split(" ");
11
  return jwt.verify(token, process.env.JWT_SECRET);
12
}
13