Setup dependencies:
npm init -y
npm i codemirror @codemirror/lang-javascript
npm i rollup @rollup/plugin-node-resolve
Create an editor:
import { AuthClient, IdTokenClient } from 'google-auth-library'; | |
const googleAuth = new GoogleAuth(); | |
const idTokenClient = await googleAuth.getIdTokenClient('https://www.example.com/'); | |
idTokenClient.gaxios.defaults.headers = { | |
'User-Agent': 'foo/1', | |
}; |
$ docker compose up | |
[+] Running 1/0 | |
✔ Container mc Recreated 0.1s | |
Attaching to mc | |
mc | DEBU[0000] Using /data to match uid and gid | |
mc | DEBU[0000] Resolved UID=0 from match path | |
mc | DEBU[0000] Resolved GID=0 from match path | |
mc | Looking up latest version... | |
mc | Updating permissions | |
mc | 2023/12/16 11:45:41 Setting level-name to OneBlock in server.properties |
Setup dependencies:
npm init -y
npm i codemirror @codemirror/lang-javascript
npm i rollup @rollup/plugin-node-resolve
Create an editor:
I want a manual trigger that when clicked will create a Campaign in my Listmonk instance, but only if the item is published.
Create a Collection called "Post" with fields:
uuid
(string, system field added during creation; this is the ID specifier)status
(string, system field added during creation)title
(string)content
(Markdown)import { ParamDecoratorEnhancer } from '@nestjs/common'; | |
import { METADATA__PARAM_TYPE } from './constants'; // METADATA__PARAM_TYPE = 'partialBodyType' | |
/** | |
* This enhancer grabs the Typescript type of the parameter and shoves it into | |
* the metadata. We do this because the CustomParamFactory does not have access | |
* to the type of param. | |
*/ | |
export const paramTypeEnhancer: ParamDecoratorEnhancer = ( | |
target: Record<string, unknown>, |
import { ArgumentMetadata, createParamDecorator, ExecutionContext } from '@nestjs/common'; | |
import { METADATA__PARAM_TYPE } from '../constants'; // METADATA__PARAM_TYPE = 'myType' | |
import { paramTypeEnhancer } from './param-type.enhancer'; | |
export const MyDecorator = createParamDecorator( | |
async (data: unknown, ctx: ExecutionContext): Promise<any> => { | |
const metatype = Reflect.getOwnMetadata(METADATA__PARAM_TYPE, ctx.getHandler()); | |
// We build the argument metadata that @nestjs/class-validator is expecting. | |
// Specifically, we specify the type as "custom" -- this is a special value |
/** | |
* Google's logging enums: | |
* DEFAULT (0) The log entry has no assigned severity level. | |
* DEBUG (100) Debug or trace information. | |
* INFO (200) Routine information, such as ongoing status or performance. | |
* NOTICE (300) Normal but significant events, such as start up, shut down, or a configuration change. | |
* WARNING (400) Warning events might cause problems. | |
* ERROR (500) Error events are likely to cause problems. | |
* CRITICAL (600) Critical events cause more severe problems or outages. | |
* ALERT (700) A person must take an action immediately. |
export class MyModel extends BaseModel { | |
@prop({ required: false, items: MyModel }) | |
items: MyModel[]; | |
} | |
export class ModelService extends BaseService { | |
async findByNestedField(key: string): Promise<MyModel> { | |
return await this.findOneAsync( | |
{ | |
items: { |
This is an example of how to ignore a global validation pipe for a specific parameter, e.g. a request body. In fact, this example just shows a request body but you could apply this principle to other decorators.
This approach assumes validateCustomDecorators: false
in the global validation pipe. If validateCustomDecorators
is true in the global pipe I think you're out of luck. If that is your situation, consider refactoring so that validateCustomDecorators
is false in the global pipe and then have each custom decorator add validation if it needs it.
The NestJS ValidationPipe
does not validate custom decorators. So, in this above example we just make a @RawBody()
param decorator, and NestJS will skip validating it.
id: blog | |
label: Blog | |
source: | |
plugin: jcr | |
host: "http://localhost:8080/server" | |
query: 'SELECT * FROM [nt:unstructured] AS node WHERE ISDESCENDANTNODE(node, "/migrate_source_jcr_example/blog") AND [sling:resourceType] = "components/structure/page"' | |
type: "JCR-SQL2" | |
user: "admin" | |
pass: "admin" | |
workspace: "default" |