![]() Relationships with PostgreSQL and MikroORM Introduction to a monorepo with Lerna and Yarn workspaces Using ETag to implement cache and save bandwidth Storing files inside a PostgreSQL database Implementing soft deletes with PostgreSQL and TypeORM Generating documentation with Compodoc and JSDoc Introduction to logging with the built-in logger and TypeORM Updating with PUT and PATCH with MongoDB and Mongoose Definining indexes with MongoDB and Mongoose Implementing pagination with MongoDB and Mongoose Managing transactions with MongoDB and Mongoose Virtual properties with MongoDB and Mongoose Verifying phone numbers and sending SMS messages with Twilio Setting up recurring payments via subscriptions with Stripe Using Stripe to save credit cards for future use Using server-side sessions instead of JSON Web Tokens Managing PostgreSQL relationships with Prisma Real-time updates with GraphQL subscriptions Sending scheduled emails with cron and Nodemailer Implementing in-memory cache to increase the performance Communicating with microservices using the gRPC framework Using RabbitMQ to communicate with microservices Offset and keyset pagination with PostgreSQL and TypeORM Using the array data type with PostgreSQL and TypeORM Defining transactions with PostgreSQL and TypeORM Improving performance of our Postgres database with indexes Testing services and controllers with integration tests Creating relationships with Postgres and TypeORM Looking into dependency injection and modules Serializing the response with interceptors Authenticating users with bcrypt, Passport, JWT, and cookies Setting up a PostgreSQL database with TypeORM Controllers, routing and the module structure This entry is part 41 of 111 in the API with NestJS Then we will create a function that will be exported and be globally accessible through the rvices. TWILIONUM will be the exact phone number given by Twilio, and MYNUM should be the destination number. Where AC82a29b91a67xxxxxxxxx is your exact ACCOUNT SID and 81682479468249xxxxxxxxxxx is the same AUTH TOKEN you copied from your Twilio account. TWILIO_ACCOUNT_SID = AC82a29b91a67xxxxxxxxx Now, copy out your ACCOUNT SID and AUTH TOKEN. Log in to Your Twilio Account or create one if you don't already have it here. Let's install Twilio using the following command: Copying Your Twilio Credentials We will send an SMS whenever a user creates a comment using Twilio. api/comment/services folder and add paste this code to it: 1 Using Services to Send SMSĬreate a file called sms.js in the. ![]() However, we can achieve endless possibilities of functionalities with the Strapi Generated Services. We want to use the Service Strapi generated to send SMS when a user creates a new comment. The above command will create an empty collection called Comments. So your selection should look like the screenshot below: We want this content type to have two fields: user and description. Next, generate a content-type with the Strapi generate command below: npm run strapi generate Your selections should look like the screenshot below: This API is not for a plugin, select n.Creating Servicesįirst, we will create an API with its configurations, controller, and service. Yarn create strapi-app my-project -quickstartĪfter installation, navigate to and complete the form to create the first Administrator user. Let's spin up a project by creating a new application if you don't have one already. Whenever you create a new content type or model, Strapi generates a new service file that does nothing but could override the generic service created in the node_module. These are reusable functions that simplify controllers' logic. ![]() Services help you with the DRY principle, as they do what they even mean they serve. Controllers are responsible for controlling the flow of any application that follows the MVC framework, including Strapi. These actions get triggered when a client requests a particular route defined in the code. Controllers are where actions are stored. Therefore, it is nice that we employ the DRY (Don't Repeat Yourself) concept all the time to make things easier. In the same vein, so many events or activities get repeated in software engineering. This action repeatedly happens whenever you go to a restaurant. Being in a restaurant, the first thing that gets presented to you is the menu. ![]()
0 Comments
Leave a Reply. |