The Ansopedia User Service is a backend service responsible for managing user accounts and authentication within the Ansopedia learning platform. It provides functionalities like:
- User Registration and Login: Enables users to create new accounts and securely log in to the platform.
- User Management: Offers APIs to manage user profiles, preferences, and potentially user roles (if permission levels exist).
- Authentication: Implements robust authentication mechanisms (e.g., JWT tokens) to secure access to Ansopedia features and resources.
- Integration: Collaborates with other services like Ansopedia Studio API to manage user permissions for content creation and interaction.
Before we dive into the steps, let's break down the scripts in your package.json
file:
- build: Transpiles TypeScript code to JavaScript.
- dev: Starts the development server with nodemon for hot reloading.
- lint: Lints the codebase using ESLint.
- lint:fix: Automatically fixes lint errors.
- prepare: Runs husky pre-commit hooks.
- pretest: Builds the project before running tests.
- prettier:check: Checks code formatting.
- prettier:fix: Fixes code formatting automatically.
- prod: Sets the NODE_ENV to production, builds the project, and starts the server.
- start: Starts the development server using ts-node.
- test: Runs the test suite.
-
Install dependencies:
pnpm install
-
Start development server:
pnpm dev
This command will start a nodemon server, which will watch for changes in your TypeScript files and automatically restart the server.
-
Start the production server:
pnpm prod
This command sets the
NODE_ENV
toproduction
, builds the project, and starts the server.
-
Run tests:
pnpm test
- Linting:
- Check for code style issues:
pnpm lint
- Automatically fix code style issues:
pnpm lint:fix
- Check for code style issues:
- Formatting:
- Check for code formatting issues:
pnpm prettier:check
- Automatically fix code formatting issues:
pnpm prettier:fix
- Check for code formatting issues:
By contributing, you agree that your contributions will be licensed under the project's LICENSE.
We welcome contributions to the Ansopedia Creator Studio! Please read our CONTRIBUTING.md for more details.
We have a CODE_OF_CONDUCT.md that outlines our expectations for behavior in the community. Please read it.
We welcome and recognize all contributors to the Ansopedia Creator Studio.
For JWT token signing and verification, this service requires RSA key pairs.
- Create a
keys
directory in the project root - Run the key generation script:
npm run generate-keys
For production environments, keys should be:
- Generated securely offline
- Stored in a secure key management service
- Mounted as secrets in the container/environment
- Never committed to version control
The expected key files are:
/keys/private.pem
- RSA private key (keep secure!)/keys/public.pem
- RSA public key (can be distributed)