Skip to content

Commit bfdfcee

Browse files
committed
✨ New Post page
1 parent cdecee3 commit bfdfcee

File tree

5 files changed

+383
-162
lines changed

5 files changed

+383
-162
lines changed

README.md

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Create Markdown Post for blog and website using Mustache Template System.
1111
- Slugify for Generate SEO Friedly Filename and Slug
1212
- Auto Date Generation
1313
- Handlebar for HTML Template page
14+
- CSRF Token - <https://expressjs.com/en/resources/middleware/csurf.html>
15+
- axios HTTP Client for Post data
1416

1517
## Development
1618

@@ -40,49 +42,7 @@ yarn start
4042
http://localhost:3005/
4143
```
4244

43-
- Post API Example
44-
45-
```sh
46-
curl --request POST \
47-
--url http://localhost:3005/ \
48-
--header 'Content-Type: application/x-www-form-urlencoded' \
49-
--data 'title=Example Post' \
50-
--data 'postcontent=Example Post - Example Blog Post via cURL.' \
51-
--data 'tag=Hello World' \
52-
--data 'description=Post Content - Hello World Blog.'
53-
```
54-
55-
```php
56-
<?php
57-
58-
$curl = curl_init();
59-
60-
curl_setopt_array($curl, [
61-
CURLOPT_PORT => "3005",
62-
CURLOPT_URL => "http://localhost:3005/",
63-
CURLOPT_RETURNTRANSFER => true,
64-
CURLOPT_ENCODING => "",
65-
CURLOPT_MAXREDIRS => 10,
66-
CURLOPT_TIMEOUT => 30,
67-
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
68-
CURLOPT_CUSTOMREQUEST => "POST",
69-
CURLOPT_POSTFIELDS => "title=Example%20Post&postcontent=Example%20Post%20-%20Example%20Blog%20Post%20via%20cURL.&tag=Hello%20World&description=Post%20Content%20-%20Hello%20World%20Blog.",
70-
CURLOPT_HTTPHEADER => [
71-
"Content-Type: application/x-www-form-urlencoded"
72-
],
73-
]);
74-
75-
$response = curl_exec($curl);
76-
$err = curl_error($curl);
77-
78-
curl_close($curl);
79-
80-
if ($err) {
81-
echo "cURL Error #:" . $err;
82-
} else {
83-
echo $response;
84-
}
85-
```
45+
- Post via API (SOON)
8646

8747
## Modification
8848

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ app.post('/post', csrfProtection, [
8383
const errors = validationResult(req);
8484

8585
if (!errors.isEmpty()) {
86-
res.status(200).json(errors);
86+
res.status(400).json(errors);
8787
} else {
8888

8989
const seo_url = slugify(blog_title, {

0 commit comments

Comments
 (0)