npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@psyrenpark/express-lib

v1.0.37

Published

viba express-lib

Downloads

39

Readme

express-lib

제작이유

serverlessExpress에서 공통된 기능 배포시 불편함 해결위해 제작

iot 추가

사용법

새버전 공지시

각 프로젝트의 cloud9에서

cd /home/ec2-user/environment/server/ServerlessExpress
npm install --save @psyrenpark/express-lib
  • 이후 최신버전으로 변경되었는지 확인할것.

미들웨어 적용

var { awsMiddleware, httpMiddleware } = require("@psyrenpark/express-lib");

app.use(require(`${__dirname}/middleware/db`));
app.use(require(`${__dirname}/middleware/auth`));

// 미들웨어 db와 auth 다음
app.use(awsMiddleware); // aws 관련 함수
app.use(httpMiddleware); // 통신 관련 함수

회원 탈퇴

  • 서버 담장자는 클라이언트에서 유저 퇄퇴 기능을 요청 받을경우 아래와같이 작성할것
  • 유저의 탈퇴는 디비와 코그니토가 연동되어 있으므로 조심할것
  • 먼저 디비 해당유저의 정보를 비활성후 성공후 코그니토 deleteUser를 실행할것
  • deleteUser는 롤백기능이 없음
  • 클라이언트는 이 api가 성공후 꼭 반드시 로그아웃후 redux, context안의 유저 정보 정리할것
  • 서버관리자에게 USER_POOL_ID 관련 작업 요청할것
app.delete("/user/:user_no", async function (req, res) {
  var result = [];
  let transaction;

  if (req.user_no !== req.param.user_no) {
    res.status(403).send({ msg: "wrong" });
    return;
  }

  try {
    transaction = await req.sequelize.transaction();

    var qeury_Deactive = req.mybatisMapper.getStatement(
      "SQL",
      "USER_DEATIVE",
      {
        user_id: req.user_id,
        user_no: req.user_no,
      },
      { language: "sql", indent: "  " }
    );

    var deactiveUserData = await req.sequelize.query(qeury_Deactive, {
      transaction: transaction,
      type: req.sequelize.QueryTypes.SELECT,
    });

    if (deactiveUserData.length !== 1) {
      throw new Error("wrong params");
    }

    var deleteUserData = await req.cognito.deleteUser({
      //주의: 배포해야 지만 작동함 (권한필요)
      username: req.user_id, //코그니토 고유 id
    });

    await transaction.commit();

    res.json({
      msg: "ok",
    });
  } catch (error) {
    if (error) await transaction.rollback();
    res.status(403).send({ msg: "wrong", error: error });
  }
});

이메일 전송

app.post("/send_email", async function (req, res) {
  var param = {
    email: "[email protected]", // req.user_info.email
    msg: "인증코드 <h2>123456</h2>", // html 문법 사용가능
    title: "싸이페어 인증메일입니다.", // 싸이페어 인증입니다.
    type: "HTML", // default   type : "TEXT"
  };

  try {
    var result = await req.ses.sendEmail(param);

    res.json({
      msg: "ok",
    });
  } catch (error) {
    res.status(403).send({ msg: "wrong", error: error });
  }
});

문자 전송

app.post("/send_sms", async function (req, res) {
  var param = {
    phone: "01000000000", //
    msg: "인증코드 123456",
    title: "싸이페어 인증문자입니다.",
  };

  try {
    var result = await req.sms.sendSMS(param);

    res.json({
      msg: "ok",
    });
  } catch (error) {
    res.status(403).send({ msg: "wrong", error: error });
  }
});

cdn clear

app.post("/clear_cdn", async function (req, res) {
  try {
    var nowDate = new Date();
    var nowTimestamp = "" + Math.round(nowDate);

    var params = {
      DistributionId: "E3NS7RWWXZFBWI", // 필요시 요청할 것
      InvalidationBatch: {
        CallerReference: nowTimestamp,
        Paths: {
          Quantity: "1",
          Items: [
            `/*`,
            // `public/test/result/${country}/${test}/${fileName}`,
          ],
        },
      },
    };

    var data = await req.cloudfront.clearCdn(params);

    console.log(data);
  } catch (error) {
    console.log(error);
  }

  res.json({
    msg: "test_test_test13-2 ok",
  });
});

푸쉬

s3 업로드

s3 인증 다운로드 링크