Skip to content

Commit

Permalink
Support CJS again (#797)
Browse files Browse the repository at this point in the history
We will also support CJS to make it a dual package. It seems that for
Typescript, it needs to be version 5.3 or higher.

Additionally, I have introduced two validators for the dual package.
1. publint https://publint.dev/
2. arethetypeswrong https://arethetypeswrong.github.io/
  • Loading branch information
Yang-33 authored Apr 2, 2024
1 parent c99f1d9 commit 09c61db
Show file tree
Hide file tree
Showing 12 changed files with 2,210 additions and 4,676 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
run: export NODE_OPTIONS=--openssl-legacy-provider; npm run docs:build
- name: Test building examples (CJS)
run: |
cd examples/echo-bot-ts
cd examples/echo-bot-ts-cjs
npm run build-sdk
npm install
npm run build
Expand All @@ -60,3 +60,7 @@ jobs:
npm install
npm run build
cd -
- name: publint
run: npx publint
- name: validate package
run: npx @arethetypeswrong/cli $(npm pack)
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# LINE Echo Bot with TypeScript
# Echo Bot for LINE using TypeScript and CJS

An example LINE bot to echo message with TypeScript. The bot is coded according to TypeScript's best practices.
Welcome to this simple guide on how to create an Echo Bot for the LINE messaging platform using TypeScript and CommonJS (CJS).
An Echo Bot is a basic bot that replies to a user's message with the same content.
This tutorial will help you set up a LINE Echo Bot from scratch.

## Prerequisite

- Git
- Node.js version 10 and up
- LINE Developers Account for the bot
- Node.js version 18 or higher
- You've created a channel in the LINE Developers Console, and got your channel access token and channel secret.
- Read https://developers.line.biz/en/docs/messaging-api/getting-started/#using-console if you haven't done this yet.

## Installation

Expand All @@ -19,7 +21,7 @@ git clone https://github.com/line/line-bot-sdk-nodejs.git
- Change directory to the example.

```bash
cd line-bot-sdk-nodejs/examples/echo-bot-ts
cd line-bot-sdk-nodejs/examples/echo-bot-ts-cjs
```

- Install all dependencies.
Expand All @@ -43,7 +45,7 @@ export PORT=<YOUR_PORT>
https://example.com/callback
```

- Compile the TypeScript files.
- Build the application.

```bash
npm run build
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const clientConfig: ClientConfig = {
};

const middlewareConfig: MiddlewareConfig = {
channelAccessToken: process.env.CHANNEL_ACCESS_TOKEN,
channelSecret: process.env.CHANNEL_SECRET || '',
};

Expand Down
Loading

0 comments on commit 09c61db

Please sign in to comment.