As your applications become more and more complex, you will find yourself refactoring your code and pulling out redundancies. By using dependency injection (DI), it is easy to create a custom class that corresponds to a set of functions that make it easy to do a specific operation. You will be able to inject your services as singletons or as new instances. This gives you plenty of flexibility to handle all sorts of scenarios in your application.
Creating a service is as simple as exporting a class. What you do in the service depends entirely on what type of functionality ...