Skip to content

Commit 30b4a99

Browse files
committed
Merge branch 'Makiwin-dev' into dev
2 parents 50dbea8 + 5e27515 commit 30b4a99

File tree

15 files changed

+11106
-20092
lines changed

15 files changed

+11106
-20092
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
/tmp
66
/out-tsc
77
.angular/cache
8-
98
# dependencies
10-
/node_modules
9+
node_modules
1110
/src/app/config.ts
1211

1312
# IDEs and editors

LICENSE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
MIT License
22

3-
Copyright (c) 2017 Wasim Nabil
3+
Copyright (c) 2017 Wasim Nabil, 2022 Massimiliano Vinciprova
4+
45

56
Permission is hereby granted, free of charge, to any person obtaining a copy
67
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 271 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,271 @@
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+
### For integrating on your project
51+
52+
```sh
53+
$ npm i @makiwin/ngx-drupal8-rest
54+
```
55+
56+
**BEFORE YOU INSTALL:** please read the [prerequisites](#prerequisites)
57+
58+
### For contribuiting to the project
59+
60+
Start with cloning this repo on your local machine:
61+
62+
```sh
63+
$ git clone https://github.com/Makiwin/ngx-drupal8-rest
64+
$ cd ngx-drupal8-rest
65+
```
66+
67+
To set up the library:
68+
69+
```sh
70+
$ npm install
71+
```
72+
73+
Or if you prefer using Yarn:
74+
75+
```sh
76+
$ yarn install
77+
```
78+
79+
## Usage
80+
81+
### Serving the library
82+
83+
```sh
84+
$ npm run watch:dev
85+
$ cd dist/ngx-drupal8-rest
86+
$ npm link
87+
```
88+
89+
### Using the library on your application
90+
91+
go to the main folder of your application and type this command
92+
```sh
93+
$ npm link ngx-drupal8-rest
94+
```
95+
96+
### Building a distribution version
97+
98+
```sh
99+
$ npm run publish
100+
```
101+
102+
This task will create a distribution version of the project
103+
inside your local `dist/` folder and will publish on npm
104+
105+
106+
<!-- ## API
107+
108+
### useBasicFetch
109+
110+
```js
111+
useBasicFetch(url: string = '', delay: number = 0)
112+
```
113+
114+
Supported options and result fields for the `useBasicFetch` hook are listed below.
115+
116+
#### Options
117+
118+
`url`
119+
120+
| Type | Default value |
121+
| --- | --- |
122+
| string | '' |
123+
124+
If present, the request will be performed as soon as the component is mounted
125+
126+
Example:
127+
128+
```tsx
129+
const MyComponent: React.FC = () => {
130+
const { data, error, loading } = useBasicFetch('https://api.icndb.com/jokes/random');
131+
132+
if (error) {
133+
return <p>Error</p>;
134+
}
135+
136+
if (loading) {
137+
return <p>Loading...</p>;
138+
}
139+
140+
return (
141+
<div className="App">
142+
<h2>Chuck Norris Joke of the day</h2>
143+
{data && data.value && <p>{data.value.joke}</p>}
144+
</div>
145+
);
146+
};
147+
```
148+
149+
`delay`
150+
151+
| Type | Default value | Description |
152+
| --- | --- | --- |
153+
| number | 0 | Time in milliseconds |
154+
155+
If present, the request will be delayed by the given amount of time
156+
157+
Example:
158+
159+
```tsx
160+
type Joke = {
161+
value: {
162+
id: number;
163+
joke: string;
164+
};
165+
};
166+
167+
const MyComponent: React.FC = () => {
168+
const { data, error, loading } = useBasicFetch<Joke>('https://api.icndb.com/jokes/random', 2000);
169+
170+
if (error) {
171+
return <p>Error</p>;
172+
}
173+
174+
if (loading) {
175+
return <p>Loading...</p>;
176+
}
177+
178+
return (
179+
<div className="App">
180+
<h2>Chuck Norris Joke of the day</h2>
181+
{data && data.value && <p>{data.value.joke}</p>}
182+
</div>
183+
);
184+
};
185+
```
186+
187+
### fetchData
188+
189+
```js
190+
fetchData(url: string)
191+
```
192+
193+
Perform an asynchronous http request against a given url
194+
195+
```tsx
196+
type Joke = {
197+
value: {
198+
id: number;
199+
joke: string;
200+
};
201+
};
202+
203+
const ChuckNorrisJokes: React.FC = () => {
204+
const { data, fetchData, error, loading } = useBasicFetch<Joke>();
205+
const [jokeId, setJokeId] = useState(1);
206+
207+
useEffect(() => {
208+
fetchData(`https://api.icndb.com/jokes/${jokeId}`);
209+
}, [jokeId, fetchData]);
210+
211+
const handleNext = () => setJokeId(jokeId + 1);
212+
213+
if (error) {
214+
return <p>Error</p>;
215+
}
216+
217+
const jokeData = data && data.value;
218+
219+
return (
220+
<div className="Comments">
221+
{loading && <p>Loading...</p>}
222+
{!loading && jokeData && (
223+
<div>
224+
<p>Joke ID: {jokeData.id}</p>
225+
<p>{jokeData.joke}</p>
226+
</div>
227+
)}
228+
{!loading && jokeData && !jokeData.joke && <p>{jokeData}</p>}
229+
<button disabled={loading} onClick={handleNext}>
230+
Next Joke
231+
</button>
232+
</div>
233+
);
234+
};
235+
``` -->
236+
237+
## Contributing
238+
239+
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
240+
241+
1. Fork it!
242+
2. Create your feature branch: `git checkout -b my-new-feature`
243+
3. Add your changes: `git add .`
244+
4. Commit your changes: `git commit -am 'Add some feature'`
245+
5. Push to the branch: `git push origin my-new-feature`
246+
6. Submit a pull request :sunglasses:
247+
248+
## Credits
249+
250+
TODO: Write credits
251+
252+
## Built With
253+
254+
* VsCode
255+
* npm
256+
* Love :heart:
257+
258+
## Versioning
259+
260+
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/your/project/tags).
261+
262+
## Authors
263+
264+
* **Wassem Keddah** - *Initial work* - [wnabil](https://github.com/wnabil)
265+
* **Massimiliano Vinciprova** - [Makiwin](https://github.com/Makiwin)
266+
267+
See also the list of [contributors](https://github.com/Makiwin/ngx-drupal8-rest/graphs/contributors) who participated in this project.
268+
269+
## License
270+
271+
[MIT License](https://mit-license.org/2019)

angular.json

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,14 @@
2020
"build": {
2121
"builder": "@angular-devkit/build-angular:browser",
2222
"options": {
23+
"preserveSymlinks": true,
2324
"outputPath": "dist/ngx-drupal8-rest-demo",
2425
"index": "src/index.html",
2526
"main": "src/main.ts",
2627
"polyfills": "src/polyfills.ts",
2728
"tsConfig": "src/tsconfig.app.json",
28-
"assets": [
29-
"src/favicon.ico",
30-
"src/assets"
31-
],
32-
"styles": [
33-
"src/styles.scss"
34-
],
29+
"assets": ["src/favicon.ico", "src/assets"],
30+
"styles": ["src/styles.scss"],
3531
"scripts": []
3632
},
3733
"configurations": {
@@ -85,26 +81,16 @@
8581
"polyfills": "src/polyfills.ts",
8682
"tsConfig": "src/tsconfig.spec.json",
8783
"karmaConfig": "src/karma.conf.js",
88-
"styles": [
89-
"src/styles.scss"
90-
],
84+
"styles": ["src/styles.scss"],
9185
"scripts": [],
92-
"assets": [
93-
"src/favicon.ico",
94-
"src/assets"
95-
]
86+
"assets": ["src/favicon.ico", "src/assets"]
9687
}
9788
},
9889
"lint": {
9990
"builder": "@angular-devkit/build-angular:tslint",
10091
"options": {
101-
"tsConfig": [
102-
"src/tsconfig.app.json",
103-
"src/tsconfig.spec.json"
104-
],
105-
"exclude": [
106-
"**/node_modules/**"
107-
]
92+
"tsConfig": ["src/tsconfig.app.json", "src/tsconfig.spec.json"],
93+
"exclude": ["**/node_modules/**"]
10894
}
10995
}
11096
}
@@ -130,14 +116,12 @@
130116
"builder": "@angular-devkit/build-angular:tslint",
131117
"options": {
132118
"tsConfig": "e2e/tsconfig.e2e.json",
133-
"exclude": [
134-
"**/node_modules/**"
135-
]
119+
"exclude": ["**/node_modules/**"]
136120
}
137121
}
138122
}
139123
},
140-
"ngx-drupal8-rest": {
124+
"@makiwin/ngx-drupal8-rest": {
141125
"root": "projects/ngx-drupal8-rest",
142126
"sourceRoot": "projects/ngx-drupal8-rest/src",
143127
"projectType": "library",
@@ -165,13 +149,11 @@
165149
"projects/ngx-drupal8-rest/tsconfig.lib.json",
166150
"projects/ngx-drupal8-rest/tsconfig.spec.json"
167151
],
168-
"exclude": [
169-
"**/node_modules/**"
170-
]
152+
"exclude": ["**/node_modules/**"]
171153
}
172154
}
173155
}
174156
}
175157
},
176158
"defaultProject": "ngx-drupal8-rest-demo"
177-
}
159+
}

0 commit comments

Comments
 (0)