This is the server side of a tour management LINE LIFF app, which also provides real-time exchange rate conversion through a LINE chatbot. It is created using Node.js, Express.js, pm2, MongoDB, Mongoose, and LINE SDK, and is hosted on Render.
- Node.js 18
- Express 4.18.2
- Mongoose 5.13.22
- pm2 5.3.1
- node-fetch-cache 4.1.0
- @line/bot-sdk 8.0.0
- Deployed on Render (The web service runs in Singapore)
- The instance will spin down with inactivity, which can delay requests by 50 seconds or more.
To run this project locally, install it using npm and set up the environment variables:
$ npm install
$ npm run dev
Add the following keys to your .env
file:
NODE_ENV=development
PORT=3001
DATABASE=your_mongoDB_connection_string
LINE_CHANNEL_ID=your_line_channel_id
LINE_CHANNEL_SECRET=your_line_channel_secret
LINE_CHANNEL_ACCESS_TOKEN=your_line_channel_access_token
Example code to fetch tour data stored in the database, sorted by date:
fetch('https://travel-helper-server.onrender.com/api/v1/tours?sort=date',
{
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer users_line_login_token_here'
}
})
- See API Documentation (The instance will spin down with inactivity, which can delay requests by 50 seconds or more)
- For the YAML file, see api.yaml on GitHub.
This app is inspired by tutorials by Jonas Schmedtmann.
- Develop common functions to handle errors and logging, reducing code duplication.
- Implement login and signup authentication processes.
- Configure CORS to restrict the domains allowed to make requests.