Contentstack Helpers: Endpoints
Tim, DX Lead at Contentstack, walks through the helper NPM package for Contentstack endpoints. The package allows you to start your region and get all the API endpoints you need to deliver your content. Endpoints NPM Package: https://www.npmjs.com/package/@timbenniks/contentstack-endpoints
Visit our docs for an in-depth write up: https://www.contentstack.com/docs/developers/kickstarts
Join our community: https://community.contentstack.com
Transcript
This is Tim from Content Stack and in this video I want to talk about an npm package that I created on my personal npm account that will help content detect developers a bunch. So let's talk about why I actually did that. Let's talk about what that my package actually is. And I'm showing you this login screen to illustrate why I had to make it. And so essentially content stack is super flexible for the big businesses that we work for. And so these businesses might have a contract with Microsoft Ashure. For them it would then be quite challenging to have all their content and all their data on AWS if we were to host there as content stack. So content stack is flexible. We provide SAS services at all these clouds. Developers need to take into account where does my data live. Am I on AWS EU or is it maybe Ashure EU? And so because of this, I created my package. And of course, you don't need that npm package to figure it out. You can just go to the docs and say, "Hey, I need image delivery specifically for North America AWS or I have my GraphQL endpoint or my brandkit endpoint." You'll find those here. And so, of course, you can make your own environment variables and, you know, fill those out. But we do see sometimes that this is quite challenging for people and so not that you're not a smart developer, but it's yet another thing to think about, right? And so that's why I created this npm package which literally just says give me your region and I'll just give you an object with all the URLs that you need. So the only thing you need to remember is I need the asset delivery URL and then you just have a word asset delivery or something like assets or GraphQL or GraphQL preview and it just gives you the URL without you having to think. So if we change URL so your software still works and so let me just show you that in action. So this is just one of our starter kits here. And so as you can see my region is EU. I just did a little console log and the object that I got back from my mpm package is all this, right? So my preview URL for visual builder is EU restreview.contentstack.com contentstack.com but my image delivery is EU images stuff like that right so I now don't have to think about what these URLs are I just need to know what these keys are so when we go to the code so I' I have two options here so our content stack delivery SDK actually has a region enum um which is like a a typescript enum and so um that region becomes that um and let's see I can show you that here. That's what that looks like. So, it kind of wants that enum, the region enum. So, but most of the time you will not have that enum, but you'll just have a little string, right? And so, in my environment variables here, my string is literally just this EU. So, I made one function to just get that specific region enum just for that string. And then I can just get my endpoints based on that enum. And there's also one where I can omit the HTTP because sometimes in our you know um SDK we we add the URLs without the HTTPS on it because the SDK does it by itself. But you can also just not do that and get the URLs with HTTP. And so now when I'm in EU this is what's coming out right. So let's now go to Ashure North America. Now, of course, my app doesn't work anymore because it's trying to query a different cloud, but you can see here that Asher North America actually now has totally different URLs here. And I didn't have to think about those URLs. It just kind of works. And so, this is just a really nice and simple little script um that will make you think a little bit less. And so right now this is actually not a core package in content stack. Um but it might be in the future but we might also come up with a different approach to this. So I didn't want to put it as a core but you can still you know grab this use it in your code and ask me for support if that's needed. All right. So if you use this feel free to tell me about it. Feel free to say hey these docs aren't correct. Join our Discord. Where's the link in the description of this video to you know chat about it. Anyways um happy coding and see you soon.
Related videos

Kickstart: Getting started with Contentstack Edge and Nuxt SSR
Tim Benniks, Developer Experience Lead, walks through a Kickstart Nuxt SSR front-end implementation.

Kickstart: Getting started with Contentstack Edge and Nuxt
Tim Benniks, Developer Experience Lead, walks through a Kickstart Nuxt front-end implementation.

Bootstrap a Kickstart in under one minute with the CLI
Contentstack offers a bootstrap cli command to get started with all Kickstarts in under one minut. Get the code running locally, and with environment variables in place.