Last active
August 6, 2024 14:11
Revisions
-
shivampip revised this gist
Nov 17, 2023 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,8 @@ cd shivam ``` * Create directus extension here ``` npm init directus-extension #old npx create-directus-extension@latest #new ``` * Select extension-type as `endpoint` * Select name as `dog` -
shivampip revised this gist
Dec 21, 2021 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,6 +22,7 @@ simple example export default (router) => { router.get("/", (req, res) => res.send("Hello World, I am Dog")); }; // accessible on /dog ``` complex example ``` @@ -38,6 +39,7 @@ module.exports = function registerEndpoint(router, { services, exceptions }) { }); }); }; // accessile on /cat/ and /cat/hello ``` * Build extension with ``` -
shivampip revised this gist
Dec 21, 2021 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,13 +16,14 @@ npm init directus-extension * Select language as `javascript` * Now go to src folder on newly created extension folder `dog/src` * Edit `index.js` file * simple example ``` export default (router) => { router.get("/", (req, res) => res.send("Hello World, I am Dog")); }; ``` complex example ``` module.exports = function registerEndpoint(router, { services, exceptions }) { router.get("/", (req, res) => { -
shivampip revised this gist
Dec 21, 2021 . 1 changed file with 17 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,10 +16,27 @@ npm init directus-extension * Select language as `javascript` * Now go to src folder on newly created extension folder `dog/src` * Edit `index.js` file * simple example ``` export default (router) => { router.get("/", (req, res) => res.send("Hello World, I am Dog")); }; ``` * complex example ``` module.exports = function registerEndpoint(router, { services, exceptions }) { router.get("/", (req, res) => { res.send({ mesasge: "Welcome to Cat world", }); }); router.get("/hello", (req, res) => { res.send({ message: "Hola from Cats", }); }); }; ``` * Build extension with ``` -
shivampip revised this gist
Dec 21, 2021 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -36,12 +36,12 @@ npm run build ``` ---docker-compose.yml ---database |---demo.db ---uploads ---extensions |---endpoints |---dog |---index.js ``` * Add volume mapping for extensions ``` -
shivampip created this gist
Dec 21, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,59 @@ ## Create Custom Endpoint in Directus ### Build Extension * Create any folder and go inside ``` mkdir shivam cd shivam ``` * Create directus extension here ``` npm init directus-extension ``` * Select extension-type as `endpoint` * Select name as `dog` * Select language as `javascript` * Now go to src folder on newly created extension folder `dog/src` * Edit `index.js` file ``` export default (router) => { router.get("/", (req, res) => res.send("Hello World, I am Dog")); }; ``` * Build extension with ``` npm run build ``` ### Deploy extension * Copy content from `dog/dist/` * Paste in `extensions/endpoints/dog` * Directus app will look like this `../extensions/endpoints/dog/index.js` ### Deploy with docker * Keep extensions folder alongside `docker-compose.yml` file ``` ---docker-compose.yml ---database ---demo.db ---uploads ---extensions ---endpoints ---dog ---index.js ``` * Add volume mapping for extensions ``` volumes: - ./uploads:/directus/uploads - ./database:/directus/database - ./extensions:/directus/extensions ``` * Done * Now run docker compose ``` sudo docker-compose up OR sudo docker-compose up -d ```