My owen mesh graphql server
npm install r-agency-meshMesh Server is a powerful, modular GraphQL server framework built with TypeScript. It provides a flexible architecture for building scalable backend applications with support for GraphQL, REST APIs, WebSockets, and more.
- GraphQL API: Built-in GraphQL server with schema generation
- Plugin System: Extensible architecture with plugin support
- Multiple Communication Protocols: HTTP, GraphQL, WebSockets
- Database Integration: Support for PostgreSQL and MySQL through TypeORM
- Authentication: Built-in authentication and authorization
- Caching: Integrated caching mechanisms
- Task Scheduling: Cron job support for scheduled tasks
- Event System: Comprehensive event management
- Media Handling: Tools for managing media files
- Performance Monitoring: Built-in performance tracking
- Node.js (v16 or higher)
- npm or yarn
- PostgreSQL or MySQL (depending on your configuration)
1. Clone the repository:
``bash`
git clone
cd mesh/server
2. Install dependencies:
`bash`
npm install
3. Configure environment variables:
- Create a .env file in the root directory
- Add required environment variables (see Configuration section)
4. Build the project:
`bash`
npm run build-dev
5. Start the development server:
`bash`
npm run dev
Mesh Server uses a combination of environment variables and configuration files:
Create a .env file in the root directory with the following variables:
`Server Configuration
HTTP_PORT=3000
GRAPHQL_PORT=4000
WEBSOCKET_PORT=5000
GRAPHQL_PATH=/graphql
$3
The
mesh.config.yml file contains additional configuration options:`yaml
server:
http-port: 3000
graphql-port: 4000
websocket-port: 5000
graphql-path: /graphql
http-request-limit: 50mb
graphql-request-limit: 50mb
`Usage
$3
Development mode:
`bash
npm run dev
`Production mode:
`bash
npm run start-prod
`Using Forever (for production):
`bash
npm run start
`$3
1. Define your GraphQL schema in the appropriate directory
2. Create resolvers for your schema
3. The server will automatically generate the necessary code
Architecture
Mesh Server follows a modular, plugin-based architecture:
$3
- Bootstrap: Initializes and starts the server
- MeshConfig: Manages configuration
- PluginManager: Handles plugin registration and execution
- EventManager: Manages event emission and handling
- GraphQlSchemaBuilder: Generates GraphQL schema
$3
- src/core: Core framework components
- async-worker: Asynchronous task processing
- auth: Authentication and authorization
- boot: System initialization
- database: Database access and management
- graphql: GraphQL implementation
- plugin: Plugin system
- websocket: WebSocket implementation
- rest-api: REST API implementation
- event-manager: Event handling
- helper: Utility functions
API Documentation
$3
The GraphQL API is available at the configured endpoint (default:
/graphql). You can use tools like GraphQL Playground or Apollo Studio to explore the API.$3
WebSocket connections are available on the configured port (default: 5000).
Development
$3
-
npm run build-dev: Build for development
- npm run build-prod: Build for production
- npm run dev: Start development server with hot reloading
- npm run lint: Run ESLint
- npm run lint:fix: Fix ESLint issues
- npm run format: Format code with Prettier
- npm run test: Run tests$3
Plugins can be added to extend the functionality of the server:
`typescript
import { startServer } from './index';
import { MyCustomPlugin } from './plugins/my-custom-plugin';startServer({
rootDir: __dirname,
loadGlobalEnv: true,
plugins: [new MyCustomPlugin()],
});
`Contributing
1. Fork the repository
2. Create a feature branch:
git checkout -b feature/my-feature
3. Commit your changes: git commit -am 'Add my feature'
4. Push to the branch: git push origin feature/my-feature`ISC License