github.com/tickoalcantara12/micro/v3@v3.0.0-20221007104245-9d75b9bcbab9/docs/blog/_posts/2020-10-16-write-your-blog-from-the-terminal.md (about) 1 --- 2 layout: post 3 author: Janos Dobronszki 4 title: "Write your blog from the terminal" 5 date: 2020-11-09 10:00:00 6 --- 7 8 If you're following our [Building a Blog with Micro](/blog/2020/11/06/building-a-blog-with-micro-part-one) series you'll already know a lot 9 about building a blog as Micro services. In this post we're going to cover a little on actually writing your blog via the terminal. We've already 10 built out the services needed so you should be able to access them in [micro/services/blog](https://github.com/micro/services/tree/master/blog). 11 12 ## Deploying the services 13 14 Make sure your env is set to dev and deploy the following services: 15 16 ```sh 17 $ micro env set dev 18 # micro signup if you don't have an account 19 $ micro env 20 local 127.0.0.1:8081 21 * dev proxy.m3o.dev 22 platform proxy.m3o.com 23 $ micro run github.com/micro/services/blogs/tags 24 $ micro run github.com/micro/services/blogs/posts 25 ``` 26 27 If you don't have an account, sign up to the dev env for a free account with the `micro signup` command after setting the env with `micro env set dev`. 28 29 After `micro status` confirms that the services are running, the services will be ready to be interacted with. 30 31 ## Terminal usage 32 33 Saving a post: 34 ```sh 35 $ micro posts save --id=1 --title="Awesome post title" --content="Even more awesome post content" 36 ``` 37 38 Listing posts 39 ``` 40 $ micro posts query 41 ``` 42 43 Listing tags 44 ``` 45 $ micro tags list 46 ``` 47 48 For a comprehensive list of commands, please refer to the readmes in the [`posts`](https://github.com/micro/services/tree/master/blog/posts) and [`tags`](https://github.com/micro/services/tree/master/blog/tags) folders. 49 50 ## Building a Netlify frontend on the Micro backend 51 52 To serve as an example, we have cooked up a very minimal (consisting of a few dozen lines of code) Angular application that uses some endpoints of these services. 53 The web app in action can be found [here](https://loving-goodall-44ee08.netlify.app/), and the source code for it can be found [here](https://github.com/micro/dev/tree/master/blog/frontend). 54 55 You can easily deploy on Netlify with the following settings: 56 57  58 59 Although example code is an Angular one, since it's using the JSON HTTP API, it's trivial to call the backend in any framework in language. The following curl contacts the posts service running in the author's namespace: 60 61 ```sh 62 $ curl -H "Micro-Namespace: hatchling-mutation-alright" https://api.m3o.dev/posts/query 63 { 64 "posts": [ 65 { 66 "id": "1", 67 "title": "Welcome to my Micro blog hosted on M3o", 68 "slug": "welcome-to-my-micro-blog-hosted-on-m3o", 69 "content": "The Dev environment of M3o is free to use and a perfect place to host your blog. All it takes is a 'micro run blog/posts && micro run blog/tags' command and you are ready to write blog posts from the terminal. In fact this entry was written in the terminal too." 70 }, 71 { 72 "id": "2", 73 "title": "Build a blog on our headless CMS", 74 "slug": "build-a-blog-on-our-headless-cms", 75 "content": "To deploy your blog all you need is a place that can host HTML files and a free M3o Dev account. Since HTML hosting is free on Github and Netlify, you can, in minutes, host your fancy blog that can be managed through the terminal." 76 } 77 ] 78 } 79 ``` 80 81 Happy hacking! 82 83 The Micro Team 84