Personal sample app to do Rest. https://github.com/anextro/RESTFuria

92 views
Skip to first unread message

Arthur Okeke

unread,
Mar 26, 2017, 5:41:20 AM3/26/17
to API Craft
Hi guys,

So sometime in the past, I did a toptal interview and that last stage required me to build a small project and expose rest api.

From the feedback I got, it turns out that one of the major reason I failed was that I did not implement Rest properly, due to my implementation,
testing will be hard.

Fast forward to some months in the future I decided to learn a little Rest and built a small rest application with Nodejs + Express I need honest critiques on the project. 

Summary of what I learnt and implemented
---------------------------------------------------------

1. The RESTApi can exists to expose an internal system.
2. The Api is capable of causing state change in the Application Data.
3. Resources are the fundamental unit of a RESTApi. Resources have a type, associated data, relationships and a set of methods that operate of it.
4. Collections are a group of Resources.
5. JSON is a good data model to use when doing REST.
6. Resources should have a type, hfref
7. How to implemente Asynchronous requests in REST.
8. Partial response and pagination. How it is important to have a default pagination setting.
etc.

I have implemented something small with just one Resource; `User`.  Also, I have added authentication using JSON web tokens.

How does this implementation make testing my REST api  possible(not possible) ?

Thank you.

Hassan Schroeder

unread,
Mar 26, 2017, 11:42:17 AM3/26/17
to api-...@googlegroups.com
On Sun, Mar 26, 2017 at 2:41 AM, Arthur Okeke <arthuru...@gmail.com> wrote:

> From the feedback I got, it turns out that one of the major reason I failed
> was that I did not implement Rest properly, due to my implementation,
> testing will be hard.
>
> Fast forward to some months in the future I decided to learn a little Rest
> and built a small rest application with Nodejs + Express

> How does this implementation make testing my REST api possible(not
> possible) ?

You realize that you could answer your own question by writing
tests for your app?

And of course the question wouldn't even be necessary if you'd
written the tests *first* :-)

FWIW,
--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote

Arthur Okeke

unread,
Mar 26, 2017, 3:20:36 PM3/26/17
to api-...@googlegroups.com
Understood. But asides the Test part, I would still appreciate some
criticisms of things I did wrongly.
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "API Craft" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/api-craft/fqfMuhKmCaE/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> api-craft+...@googlegroups.com.
> Visit this group at https://groups.google.com/group/api-craft.
> For more options, visit https://groups.google.com/d/optout.
>

Hassan Schroeder

unread,
Mar 26, 2017, 6:23:16 PM3/26/17
to api-...@googlegroups.com
On Sun, Mar 26, 2017 at 12:20 PM, Arthur Okeke
<arthuru...@gmail.com> wrote:
> Understood. But asides the Test part, I would still appreciate some
> criticisms of things I did wrongly.

I think it's very hard to critique an "implementation" without seeing
actual code -- vague generalities aren't much to go on :-)

Arthur Okeke

unread,
Mar 26, 2017, 6:45:40 PM3/26/17
to API Craft
Hi Hassan,

I actually have sample code on github already https://github.com/anextro/RESTFuria

Hassan Schroeder

unread,
Mar 27, 2017, 10:21:46 AM3/27/17
to api-...@googlegroups.com
On Sun, Mar 26, 2017 at 3:45 PM, Arthur Okeke <arthuru...@gmail.com> wrote:

> I actually have sample code on github already
> https://github.com/anextro/RESTFuria

Ah, apologies, missed that in the title.

Caveat: not familiar with Express, not a Node person, but it looks
reasonable to me. (I got the app running locally but didn't have time
to figure out how to get past the auth requirement which apparently
applies to every route.)

But I still say tests are the answer :-) Have you looked at Postman
(https://www.getpostman.com/) at all? Just started working with it
at $dayjob and it seems useful/usable.

FWIW!

Arthur Okeke

unread,
Mar 27, 2017, 11:31:50 AM3/27/17
to api-...@googlegroups.com
Yes, I work with postman. Thanks for you comments. I will write the tests soon.

Arthur Okeke

unread,
Apr 1, 2017, 7:45:45 PM4/1/17
to API Craft
Tests have been written. I easily wrote the test. I assume for now that the api will be easy to integrate to.
I have also added an Article sub resource
Reply all
Reply to author
Forward
0 new messages