Skip to content

acent sdk 사용법

Dongmin Shin edited this page Dec 10, 2020 · 2 revisions

설치방법

node 기반 : npm install @acent/node or yarn add @acent/node
react : npm install @acent/react or yarn add @acent/react

express.js

import * as express from 'express';
import * as cookieParser from 'cookie-parser';
import * as passport from 'passport';
import * as cors from 'cors';
import * as morgan from 'morgan';
import * as acent from '@acent/node'; // import
import initPassport from './passport';
import routerBundle from './routes/index';
import getConnection from './mongo';

const app: express.Application = express();

getConnection();
initPassport();
app.use(
  cors({
    origin: true,
    credentials: true,
  })
);
acent.startErrorCapturing();
acent.init({
  dsn: '[host:port]/errorevent/[project id]',
// ex : http://localhost:3000/errorevent/5fcd71921c7d7f09e08dd1d0
});

app.use(morgan('combined'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(passport.initialize());

app.use('/', routerBundle);
//에러 핸들러는 라우터 미들웨어 뒤에, 다른 에러핸들링 미들웨어 이전에 위치
app.use((acent.errorHandler() as unknown) as express.ErrorRequestHandler);  //typescript type 오류로 typescript에서는 이렇게 사용해야함
//커스텀 에러핸들링 미들웨어
export default app;
Clone this wiki locally