Coder Social home page Coder Social logo

langx / api Goto Github PK

View Code? Open in Web Editor NEW
12.0 2.0 3.0 448 KB

Server Api for LangX clients

Home Page: https://status.langx.io

License: MIT License

TypeScript 100.00%
api exchange expressjs language languageexchange nodejs open-source server edtech language-exchange

api's Introduction

Better Stack Badge

API Server

This project is a Node.js application. Before you can run it, you need to set up your environment.

Prerequisites

Before running the application, ensure that you have the following installed on your machine:

  • Node.js
  • npm

Installation

  1. Clone the repository to your local machine.
  2. Navigate to the project directory.
  3. Install the project dependencies by running:
npm install
  1. Build the project by running:
npm run build
  1. Install pm2 globally. pm2 is a production process manager for Node.js applications with a built-in load balancer. You can install it by running:
npm install pm2 -g

Configuration

This project uses environment variables for configuration. These are stored in a .env file. A sample .env.sample file is provided in the repository.

To use the .env.sample file:

  1. Copy the .env.sample file and rename the copy to .env.
  2. Replace the placeholder values in the .env file with your actual values.

Running the Server

After you've set up your environment, you can start the server by running:

pm2 start dist/server.js --name server-api -i 3

To ensure that the server restarts when the system reboots, run:

pm2 startup
pm2 save

Conclusion

That's it! You've now set up and run the server. If you have any issues, please open an issue.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Please note that this license does not cover any third-party libraries or dependencies used in this project. Those libraries and dependencies are covered by their respective licenses.

api's People

Contributors

dependabot[bot] avatar xuelink avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

api's Issues

๐Ÿš€ : Ensure Consistent User Order in Room Data Initialization

Is your feature request related to a problem? Please describe.
I'm always frustrated when the order of users in the users array is inconsistent in the roomData object. Currently, the order is only reassigned when sender is greater than to, which can lead to unpredictability and potential issues when comparing or processing room data.

Describe the solution you'd like
I would like to improve the initialization of the roomData object to ensure a consistent and predictable order of user IDs. This can be achieved by sorting the users array numerically and then converting the user IDs back to strings. This approach guarantees that the user IDs are always stored in a consistent order.

Describe alternatives you've considered
An alternative solution could be to conditionally assign the roomData object only when sender is greater than to, as currently implemented. However, this approach does not ensure a consistent order of user IDs in all cases, which can lead to potential issues.

Additional context
Here is the improved version of the code to ensure consistent user order:

let roomData = {
  users: [sender, to].map(String).sort((a, b) => a.localeCompare(b)),
  copilot: [],
  typing: [false, false],
  unseen: [0, 0],
};

Contributor: @gab within the app

This version sorts the user IDs as strings, ensuring a consistent and predictable order in the users array.

If you want to speed up the process of this issue, please send ๐Ÿš€ as a reaction.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.