Skip to content

Commit d5c29d7

Browse files
committed
updated readme.md
1 parent 6e70757 commit d5c29d7

File tree

1 file changed

+263
-1
lines changed

1 file changed

+263
-1
lines changed

README.md

Lines changed: 263 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,263 @@
1-
## TODO
1+
[![npm version](https://badge.fury.io/js/angular2-expandable-list.svg)](https://badge.fury.io/js/angular2-expandable-list)
2+
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
3+
4+
# ngx-drupal8-rest
5+
6+
> A wrapper library to connect to a Drupal8 based backend
7+
8+
## Prerequisites
9+
10+
This project requires NodeJS (version 8 or later) and NPM.
11+
[Node](http://nodejs.org/) and [NPM](https://npmjs.org/) are really easy to install.
12+
To make sure you have them available on your machine,
13+
try running the following command.
14+
15+
```sh
16+
$ npm -v && node -v
17+
6.14.17
18+
v16.17.1
19+
```
20+
21+
## Table of contents
22+
23+
- [Project Name](#project-name)
24+
- [Prerequisites](#prerequisites)
25+
- [Table of contents](#table-of-contents)
26+
- [Getting Started](#getting-started)
27+
- [Installation](#installation)
28+
- [Usage](#usage)
29+
- [Serving the app](#serving-the-app)
30+
- [Running the tests](#running-the-tests)
31+
- [Building a distribution version](#building-a-distribution-version)
32+
- [Serving the distribution version](#serving-the-distribution-version)
33+
<!-- - [API](#api)
34+
- [useBasicFetch](#usebasicfetch)
35+
- [Options](#options)
36+
- [fetchData](#fetchdata) -->
37+
- [Contributing](#contributing)
38+
- [Credits](#credits)
39+
- [Built With](#built-with)
40+
- [Versioning](#versioning)
41+
- [Authors](#authors)
42+
- [License](#license)
43+
44+
## Getting Started
45+
46+
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
47+
48+
## Installation
49+
50+
**BEFORE YOU INSTALL:** please read the [prerequisites](#prerequisites)
51+
52+
Start with cloning this repo on your local machine:
53+
54+
```sh
55+
$ git clone https://github.com/Makiwin/ngx-drupal8-rest
56+
$ cd ngx-drupal8-rest
57+
```
58+
59+
To set up the library:
60+
61+
```sh
62+
$ npm install
63+
```
64+
65+
Or if you prefer using Yarn:
66+
67+
```sh
68+
$ yarn install
69+
```
70+
71+
## Usage
72+
73+
### Serving the library
74+
75+
```sh
76+
$ npm run watch:dev
77+
$ cd dist/ngx-drupal8-rest
78+
$ npm link
79+
```
80+
81+
### Using the library on your application
82+
83+
go to the main folder of your application and type this command
84+
```sh
85+
$ npm link ngx-drupal8-rest
86+
```
87+
88+
### Building a distribution version
89+
90+
```sh
91+
$ npm run publish
92+
```
93+
94+
This task will create a distribution version of the project
95+
inside your local `dist/` folder and will publish on npm
96+
97+
98+
<!-- ## API
99+
100+
### useBasicFetch
101+
102+
```js
103+
useBasicFetch(url: string = '', delay: number = 0)
104+
```
105+
106+
Supported options and result fields for the `useBasicFetch` hook are listed below.
107+
108+
#### Options
109+
110+
`url`
111+
112+
| Type | Default value |
113+
| --- | --- |
114+
| string | '' |
115+
116+
If present, the request will be performed as soon as the component is mounted
117+
118+
Example:
119+
120+
```tsx
121+
const MyComponent: React.FC = () => {
122+
const { data, error, loading } = useBasicFetch('https://api.icndb.com/jokes/random');
123+
124+
if (error) {
125+
return <p>Error</p>;
126+
}
127+
128+
if (loading) {
129+
return <p>Loading...</p>;
130+
}
131+
132+
return (
133+
<div className="App">
134+
<h2>Chuck Norris Joke of the day</h2>
135+
{data && data.value && <p>{data.value.joke}</p>}
136+
</div>
137+
);
138+
};
139+
```
140+
141+
`delay`
142+
143+
| Type | Default value | Description |
144+
| --- | --- | --- |
145+
| number | 0 | Time in milliseconds |
146+
147+
If present, the request will be delayed by the given amount of time
148+
149+
Example:
150+
151+
```tsx
152+
type Joke = {
153+
value: {
154+
id: number;
155+
joke: string;
156+
};
157+
};
158+
159+
const MyComponent: React.FC = () => {
160+
const { data, error, loading } = useBasicFetch<Joke>('https://api.icndb.com/jokes/random', 2000);
161+
162+
if (error) {
163+
return <p>Error</p>;
164+
}
165+
166+
if (loading) {
167+
return <p>Loading...</p>;
168+
}
169+
170+
return (
171+
<div className="App">
172+
<h2>Chuck Norris Joke of the day</h2>
173+
{data && data.value && <p>{data.value.joke}</p>}
174+
</div>
175+
);
176+
};
177+
```
178+
179+
### fetchData
180+
181+
```js
182+
fetchData(url: string)
183+
```
184+
185+
Perform an asynchronous http request against a given url
186+
187+
```tsx
188+
type Joke = {
189+
value: {
190+
id: number;
191+
joke: string;
192+
};
193+
};
194+
195+
const ChuckNorrisJokes: React.FC = () => {
196+
const { data, fetchData, error, loading } = useBasicFetch<Joke>();
197+
const [jokeId, setJokeId] = useState(1);
198+
199+
useEffect(() => {
200+
fetchData(`https://api.icndb.com/jokes/${jokeId}`);
201+
}, [jokeId, fetchData]);
202+
203+
const handleNext = () => setJokeId(jokeId + 1);
204+
205+
if (error) {
206+
return <p>Error</p>;
207+
}
208+
209+
const jokeData = data && data.value;
210+
211+
return (
212+
<div className="Comments">
213+
{loading && <p>Loading...</p>}
214+
{!loading && jokeData && (
215+
<div>
216+
<p>Joke ID: {jokeData.id}</p>
217+
<p>{jokeData.joke}</p>
218+
</div>
219+
)}
220+
{!loading && jokeData && !jokeData.joke && <p>{jokeData}</p>}
221+
<button disabled={loading} onClick={handleNext}>
222+
Next Joke
223+
</button>
224+
</div>
225+
);
226+
};
227+
``` -->
228+
229+
## Contributing
230+
231+
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
232+
233+
1. Fork it!
234+
2. Create your feature branch: `git checkout -b my-new-feature`
235+
3. Add your changes: `git add .`
236+
4. Commit your changes: `git commit -am 'Add some feature'`
237+
5. Push to the branch: `git push origin my-new-feature`
238+
6. Submit a pull request :sunglasses:
239+
240+
## Credits
241+
242+
TODO: Write credits
243+
244+
## Built With
245+
246+
* VsCode
247+
* npm
248+
* Love :love:
249+
250+
## Versioning
251+
252+
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/your/project/tags).
253+
254+
## Authors
255+
256+
* **Wassem Keddah** - *Initial work* - [wnabil](https://github.com/wnabil)
257+
* **Massimiliano Vinciprova** - [Makiwin](https://github.com/Makiwin)
258+
259+
See also the list of [contributors](https://github.com/Makiwin/ngx-drupal8-rest/graphs/contributors) who participated in this project.
260+
261+
## License
262+
263+
[MIT License](https://mit-license.org/2019)

0 commit comments

Comments
 (0)