|

Building a Full-Stack Component. Discover how full-stack components… | by Mike Chen

Build in AI speed — Compose enterprise-grade applications, features, and components

.
└── people
├── people-config.ts # the aspect’s configuration options
├── people.aspect.ts # the aspect’s manifest file
├── people.browser.runtime.ts # the aspect’s browser runtime entry point
├── people.browser.spec.ts # the aspect’s browser test file
├── people.docs.mdx # the aspect’s documentation
├── people.node.runtime.ts # the aspect’s node runtime entry point
├── people.node.spec.ts # the aspect’s node test file
├── index.ts # the component’s entry point
└── menu-list-items.ts # the aspect’s integration slotThe “people” aspect on Bit Platform

See Also  How I Get Free Traffic from ChatGPT in 2025 (AIO vs SEO)

/**
* @filename pied-piper.bit-app.ts
*/

import { PeopleAspect } from ‘@pied/people.people’;
// …

export const PiedPiper = HarmonyPlatform.from({
name: ‘pied-piper’,
platform: [
SymphonyPlatformAspect,
{
name: ‘PiedPiper’,
slogan: ‘Platform’,
logo: ‘https://static.bit.dev/extensions-icons/wayne.svg’,
},
],

runtimes: [new BrowserRuntime(), new NodeJSRuntime()],

aspects: [PeopleAspect, BlogAspect, PaymentAspect],
});

/**
* @componentId: pied.people/people
* @filename people.node.runtime.ts
*/

import {
SymphonyPlatformNode,
SymphonyPlatformAspect,
} from ‘@bitdev/symphony.symphony-platform’;
import { createPeopleGqlSchema } from ‘./people.graphql.js’;
import {
PiedPlatformNode,
PiedPlatformAspect,
} from ‘@pied/pied-piper.pied-platform’;
// …

export class PeopleNode {
// …

async getCurrentUser(req: any): Promise {
// …
return User.from(user);
}

static dependencies = [SymphonyPlatformAspect];

static async provider([symphonyPlatform]: [
SymphonyPlatformNode
]) {
const gqlSchema = createPeopleGqlSchema(people);

/**
* Register a GraphQL schema to the platform’s backend server.
*/
piedPlatform.registerBackendServer([
{
routes: [],
gql: gqlSchema,
},
]);

/**
* Register to the platform’s middleware to intercept requests to the backend
* and attach the user to the request.
*/
symphonyPlatform.registerMiddlewares([
(req, _, next) => {
const user = people.getCurrentUser(req);
req.user = user;
next();
},
]);

return people;
}
}

export default PeopleNode;

See Also  Better CSS Shapes Using shape() — Part 1: Lines and Arcs

Source link

Similar Posts