SDK
Search
K

Art Module

Generating the art module

Create module

This creates a new codegen module
pnx g @logosphere/sdk:module --name art
Take a look at the project structure under libs/art-gen/src

Edit model file

In this step, similar to the music module, we will create a simple model for the art domain, consisting of Artist and Artwork entities.
For the complete list of model properties check the Logosphere Modelling documentation.
Modify libs/art-gen/src/art.model.ts file:
/* eslint-disable @typescript-eslint/no-unused-vars */
import { Entity, Prop } from '@logosphere/decorators';
@Ent('artist')
export class Artist {
@Prop({
examples: ['Beeple', '3LAU', 'WhisBe'],
})
name: string;
}
@Ent('artwork')
export class Artwork {
@Prop({
examples: ['The First 5000 Days', 'All Night Long', 'Gold Gummy Bear'],
})
title: string;
@Prop({
examples: ['Most famous Beeples work', 'Best work', 'It is about a gold gummy bear'],
})
description: string;
@Prop({ type: () => Artist, index: false })
author: Artist;
}

Generate art module API

pnx affected:build
pnx g @logosphere/sdk:api --module art

Build & test art module API

pnx affected:build
pnx affected:test

Re-generate docker-compose and .env

To add Art application to existing stack, docker-compose generator need to be called again.
pnx g @logosphere/sdk:docker-compose
Existing .env and docker-compose.yaml will be overridden. If you made some changes in previous set you have to configure it again

Run up the art service

Similar like before the service can be run as part of stack
docker-compose up
Or can be serve as standalone container
pnx docker art --port=4001

Test API endpoint

Check schema that it matches the art module

Create an artwork

Mutation:
mutation artworkCreate($artwork: ArtworkInput!) {
artworkSave(artwork: $artwork) {
id
subjectId
title
description
createdAt
updatedAt
}
}
Variables:
{
"artwork": {
"title": "The first 5000 days",
"description": "Most famous Beeple work",
"author": {
"name": "Beeple"
}
}
}
Output:
{
"data": {
"artworkSave": {
"id": "c12d4725ee5dc9870e23f51cf06d09260aebfa9c17c3a1111cd96a2a9406752a",
"subjectId": "369435906932736",
"title": "The first 5000 days",
"description": "Most famous Beeple work",
"createdAt": "2022-07-21T04:48:33.374Z",
"updatedAt": "2022-07-21T04:48:33.374Z"
}
}
}