Strapi
Overview¶
Strapi is an open-source headless CMS that gives developers the freedom to choose their favorite tools and frameworks and allows editors to manage and distribute their content using their application’s admin panel. Based on a plugin system, its admin panel and API are extensible. Every part is customizable to match any use case. Strapi also has a built-in user system to manage what the administrators and end users can access.
Prerequisites¶
- You should have an Astra account
- You should Create an Astra Database
- You should Have an Astra Token
- You should retrieve your **Database ID** and **Region** from your Astra DB dashboard
- Install node (14.17.3 version).
Installation and Setup¶
Follow the steps below to setup Strapi locally.
-
First, install Strapi locally:
You can view your Strapi project as it is hosted locally at http://localhost:1337/admin. -
Install the Strapi hook:
-
Activate the hook by adding the following to
Where:./config/hook.js
of the sample Strapi Project: token
: Generate a token from Astra DB.databaseId
: Enter your Astra DB database ID from your database URL.databaseRegion
: Enter your Astra DB database regionkeyspace
: Enter your Astra DB keyspace name.collection
: Enter your Astra DB collection name.
Test and Validate¶
-
Create a document:
|Parameter|Type|Explanation|Values| |:---|:---|:---|:---| |document|json|Create a document|var dataString = '{ "name": "John", "last_name": "Doe" }'| -
Get document by ID:
|Parameter|Type|Explanation|Values| |:---|:---|:---|:---| |documentId|string|Get document by documentId|var documentId = "your_document_id"| -
Get document by path:
-
Search a collection:
|Parameter|Type|Explanation|Values| |:---|:---|:---|:---| |query|string|Search collection via query|var query = {"name": { "$eq": "John" }}| |pagesize|int|Number of documents to fetch|int page_size = 3|
For more, see the Strapi documentation.
Last update:
2023-10-13