Advertisement · 728 × 90

Posts by Martin Paucot

ViteJS website showcasing all frameworks that use it, with AdonisJS featured among them

ViteJS website showcasing all frameworks that use it, with AdonisJS featured among them

@vite.dev is the default asset bundler in every AdonisJS app.

Not only does it bundle your frontend assets, but its API also enables server-side rendering of your #InertiaJS codebase, making your app even more powerful.

We're excited to be featured on their website today! 🙌

1 year ago 43 5 1 1
import { BaseModel, column } from "@adonisjs/lucid/orm";
import { ObjectType, Field } from "@foadonis/graphql/decorators"; 
import { DateTime } from "luxon";
 
@ObjectType() 
export default class Recipe extends BaseModel {
  @column({ isPrimary: true })
  @Field((type) => ID) 
  declare id: string;
 
  @column()
  @Field() 
  declare title: string;
 
  @column()
  @Field({ nullable: true }) 
  declare description: string | null;
 
  @column()
  @Field(() => [String]) 
  declare ingredients: string[];
}

import { BaseModel, column } from "@adonisjs/lucid/orm"; import { ObjectType, Field } from "@foadonis/graphql/decorators"; import { DateTime } from "luxon"; @ObjectType() export default class Recipe extends BaseModel { @column({ isPrimary: true }) @Field((type) => ID) declare id: string; @column() @Field() declare title: string; @column() @Field({ nullable: true }) declare description: string | null; @column() @Field(() => [String]) declare ingredients: string[]; }

import Recipe from "#models/recipe";
import { Arg, Args, Int, Mutation, Query, Resolver } from "type-graphql";
 
@Resolver(Recipe)
export default class RecipeResolver {
  @Query(() => Recipe)
  recipe(@Arg("id") id: number) {
    return Recipe.findOrFail(id);
  }
 
  @Query(() => [Recipe])
  recipes(@Args() { page, perPage }: RecipeArgs) {
    return Recipe.query().paginate(page, perPage);
  }
 
  @Mutation(() => Recipe)
  addRecipe(@Arg("newRecipeData") newRecipeData: NewRecipeInput) {
    return Recipe.create(newRecipeData);
  }
 
  @Mutation(() => Boolean)
  async removeRecipe(@Arg("id") id: number) {
    const recipe = await Recipe.find(id);
 
    if (!recipe) {
      return false;
    }
 
    await recipe.delete();
    return true;
  }
}

import Recipe from "#models/recipe"; import { Arg, Args, Int, Mutation, Query, Resolver } from "type-graphql"; @Resolver(Recipe) export default class RecipeResolver { @Query(() => Recipe) recipe(@Arg("id") id: number) { return Recipe.findOrFail(id); } @Query(() => [Recipe]) recipes(@Args() { page, perPage }: RecipeArgs) { return Recipe.query().paginate(page, perPage); } @Mutation(() => Recipe) addRecipe(@Arg("newRecipeData") newRecipeData: NewRecipeInput) { return Recipe.create(newRecipeData); } @Mutation(() => Boolean) async removeRecipe(@Arg("id") id: number) { const recipe = await Recipe.find(id); if (!recipe) { return false; } await recipe.delete(); return true; } }

Heard some of you are into #GraphQL?

Thanks to @martin-paucot.fr, you can now compose your Object Type from our Lucid Model and perform CRUD operations on it!

🔗 friendsofadonis.com/docs/graphql

1 year ago 8 3 1 0
import { ApiProperty, ApiOptionalProperty } from "@foadonis/openapi";
 
export default class Post {
  @ApiProperty()
  id: number;
 
  @ApiProperty()
  title: string;
 
  @ApiOptionalProperty()
  content?: string;
}

import { ApiProperty, ApiOptionalProperty } from "@foadonis/openapi"; export default class Post { @ApiProperty() id: number; @ApiProperty() title: string; @ApiOptionalProperty() content?: string; }

Any OpenAPI enthusiasts here?

@martin-paucot.fr has released another package to generate OpenAPI v3-compliant specifications using TypeScript decorators. 🙌

➡️ friendsofadonis.com/docs/openapi

1 year ago 16 4 0 0
Preview
Introduction | Adonis OpenAPI Generate OpenAPI V3 specifications for your Adonis application

New Adonis package unlocked!

friendsofadonis.com/docs/openapi

1 year ago 3 2 0 0
export class BillingController {

  async checkout({ auth, request, view }: HttpContext) {
    const user = auth.getUserOrFail()
    
    const checkout = await user
      .newSubscription()
      .price('price_tshirt')
      .quantity(5)
      .checkout()

    return view.render('pages/checkout', {
      checkout
    })
  }

}

export class BillingController { async checkout({ auth, request, view }: HttpContext) { const user = auth.getUserOrFail() const checkout = await user .newSubscription() .price('price_tshirt') .quantity(5) .checkout() return view.render('pages/checkout', { checkout }) } }

One of our community member (@paucotmartin.bsky.social) keeps delivering amazing packages! 🙌

Today, check out Shopkeeper—offering a smooth, fluent interface for Stripe's subscription billing services.

➡️ friendsofadonis.github.io/docs/shopkee...

1 year ago 18 3 0 0