Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!-- CONTRIBUTING -->

## Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.

If you have a suggestion to better our API, please fork the repo and create a pull request. Additionally, you can open an issue and offer advice.
Don't forget to give the project a star! Thanks again!

1. Visit our Issues page to check if an issue exists and does not have an assignee.
2. Fork the Project
3. Change to your Feature Branch (`git checkout -b feature/AmazingFeature`)
4. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
5. Push to the Branch (`git push origin feature/AmazingFeature`)
6. Open a Pull Request
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 the-api-administration

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
154 changes: 154 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
# Coding-Resources-API

<div id="top"></div>

[![Contributors][contributors-shield]][contributors-url]
[![Forks][forks-shield]][forks-url]
[![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url]
[![MIT License][license-shield]][license-url]

<!-- PROJECT LOGO -->
<br />
<div align="center">
<a href="https://github.com/the-api-administration">
<img src="https://avatars.githubusercontent.com/u/106885719?s=200&v=4" alt="Logo" width="80" height="80">
</a>

<h3 align="center">Coding Resources API</h3>

<p align="center">
Provides Coding Resources
<br />
<a href="https://github.com/the-api-administration/coding-resources-api"><strong>Explore the docs »</strong></a>
<br />
<br />
<a href="https://coding-resources-api.herokuapp.com/">View Demo</a>
·
<a href="https://github.com/the-api-administration/coding-resources-api/issues">Report Bug</a>
·
<a href="https://github.com/the-api-administration/coding-resources-api/issues">Request Feature</a>
</p>
</div>

<!-- TABLE OF CONTENTS -->
<details>
<summary>Table of Contents</summary>
<ol>
<li>
<a href="#about-the-project">About The Project</a>
<ul>
<li><a href="#built-with">Built With</a></li>
</ul>
</li>
<li><a href="#getting-started">Getting Started</a></li>
<li><a href="#usage">Usage</a></li>
<li><a href="#roadmap">Roadmap</a></li>
<li><a href="#contributing">Contributing</a></li>
<li><a href="#license">License</a></li>
<li><a href="#acknowledgments">Acknowledgments</a></li>
</ol>
</details>

<!-- ABOUT THE PROJECT -->

## About The Project

Search for coding resources by relevant keywords. This API serves educational content for a wide variety of computer science topics, languages and technologies relevant to web development.

<p align="right">(<a href="#top">back to top</a>)</p>

### Built With

- EJS
- CSS
- JavaScript
- Node.js
- Express

<p align="right">(<a href="#top">back to top</a>)</p>

<!-- GETTING STARTED -->

## Getting Started

Simply visit: <a href="https://coding-resources-api.herokuapp.com/">https://coding-resources-api.herokuapp.com/</a> and read our documentation to learn how to interact with our API! If you would like to help us out, feel free to create issues through our github repo.

<p align="right">(<a href="#top">back to top</a>)</p>

<!-- USAGE EXAMPLES -->

## Usage

Access our API endpoints to recieve coding resource data in JSON format.

<p align="right">(<a href="#top">back to top</a>)</p>

<!-- ROADMAP -->

## Roadmap

- [X] Add search functionality
- [ ] Offer more resources
- [ ] Support mobile devices
- [ ] Create more endpoints

See the [open issues](https://github.com/the-api-administration/coding-resources-api/issues) for a full list of proposed features (and known issues).

<p align="right">(<a href="#top">back to top</a>)</p>

<!-- CONTRIBUTING -->

## Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.

If you have a suggestion to better our API, please fork the repo and create a pull request. Additionally, you can open an issue and offer advice.
Don't forget to give the project a star! Thanks again!

1. Visit our Issues page to check if an issue exists and does not have an assignee.
2. Fork the Project
3. Change to your Feature Branch (`git checkout -b feature/AmazingFeature`)
4. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
5. Push to the Branch (`git push origin feature/AmazingFeature`)
6. Open a Pull Request

<p align="right">(<a href="#top">back to top</a>)</p>

<!-- LICENSE -->

## License

Distributed under the MIT License. See <a href="https://github.com/the-api-administration/coding-resources-api/blob/main/LICENSE.md">`LICENSE.md`</a> for more information.

<p align="right">(<a href="#top">back to top</a>)</p>

<!-- ACKNOWLEDGMENTS -->

## Acknowledgments

- [@AlexisInTech](https://twitter.com/alexisintech)
- [@AlysshaLewin](https://twitter.com/AlysshaLewin)
- [@Asper_Jacob](https://twitter.com/asper_jacob)
- [@BrianSchneeDev](https://twitter.com/BrianSchneeDev)
- [@BytesByBianca](https://twitter.com/bytesbybianca)
- [@DanaMiteCoder](https://twitter.com/danamitecoder)
- [@Dev_Ethos](https://twitter.com/dev_ethos/)
- [@ErikaTeal_](https://twitter.com/erikateal_)
- [@JacobEGood](https://twitter.com/jacobegood)
- [@MoraCodes](https://twitter.com/moracodes)

<p align="right">(<a href="#top">back to top</a>)</p>

<!-- MARKDOWN LINKS & IMAGES -->

[contributors-shield]: https://img.shields.io/github/contributors/the-api-administration/coding-resources-api.svg?style=for-the-badge
[contributors-url]: https://github.com/the-api-administration/coding-resources-api/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/the-api-administration/coding-resources-api.svg?style=for-the-badge
[forks-url]: https://github.com/the-api-administration/coding-resources-api/network/members
[stars-shield]: https://img.shields.io/github/stars/the-api-administration/coding-resources-api.svg?style=for-the-badge
[stars-url]: https://github.com/the-api-administration/coding-resources-api/stargazers
[issues-shield]: https://img.shields.io/github/issues/the-api-administration/coding-resources-api.svg?style=for-the-badge
[issues-url]: https://github.com/the-api-administration/coding-resources-api/issues
[license-shield]: https://img.shields.io/github/license/the-api-administration/coding-resources-api.svg?style=for-the-badge
[license-url]: https://github.com/the-api-administration/coding-resources-api/blob/master/LICENSE.md
19 changes: 10 additions & 9 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const express = require('express');
const app = express();
const cors = require('cors');
const { resources } = require("./resources");
const { response } = require('express');
const e = require('express');
const PORT = process.env.PORT || 8000;

app.set('view engine', 'ejs')
Expand Down Expand Up @@ -31,15 +33,14 @@ app.get('/api/:keyword', (req, res) => {
// filter resources array, return items that match query; tag.
const matches = resources.filter((obj) => obj.keywords.some(str => str.includes(keyword)));

try {
// if matches were found respond with json
if (matches.length) {
res.json(matches);
} else {
throw new Error('No resources found.');
}
} catch(err) {
console.error(err);
// if matches were found, respond with matches array in JSON format
if (matches.length) {
res.json(matches);
} else {
// respond with status 404, no matches were found
res.status(404).json({
error: `No resources were found with the ${keyword} keyword.`
});
}
});

Expand Down